Class: Eancom::Edifact::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/eancom/edifact/item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeItem

Returns a new instance of Item.



7
8
9
# File 'lib/eancom/edifact/item.rb', line 7

def initialize
  @hash = {}
end

Instance Attribute Details

#hashObject

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

Returns:

  • (Boolean)


24
25
26
# File 'lib/eancom/edifact/item.rb', line 24

def empty?
  @hash.empty?
end

#to_json_hashObject



20
21
22
# File 'lib/eancom/edifact/item.rb', line 20

def to_json_hash
  @hash
end