Class: Eancom::Edifact::Item
- Inherits:
-
Object
- Object
- Eancom::Edifact::Item
- Defined in:
- lib/eancom/edifact/item.rb
Instance Attribute Summary collapse
-
#hash ⇒ Object
Returns the value of attribute hash.
Instance Method Summary collapse
- #<<(segment) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize ⇒ Item
constructor
A new instance of Item.
- #to_json_hash ⇒ Object
Constructor Details
#initialize ⇒ Item
Returns a new instance of Item.
7 8 9 |
# File 'lib/eancom/edifact/item.rb', line 7 def initialize @hash = {} end |
Instance Attribute Details
#hash ⇒ Object
Returns the value of attribute hash.
5 6 7 |
# File 'lib/eancom/edifact/item.rb', line 5 def hash @hash end |
Instance Method Details
#<<(segment) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/eancom/edifact/item.rb', line 11 def << (segment) if name = group_name(segment) @hash[name] = [] if @hash[name].nil? @hash[name] << segment.to_json_hash else @hash.merge!(segment.to_json_hash) end end |
#empty? ⇒ Boolean
24 25 26 |
# File 'lib/eancom/edifact/item.rb', line 24 def empty? @hash.empty? end |
#to_json_hash ⇒ Object
20 21 22 |
# File 'lib/eancom/edifact/item.rb', line 20 def to_json_hash @hash end |