Sha256: 79bc5fc1fa72d1f1b2c7df5231bb599187a26a91ecd1e7835e3dce8293396b93
Contents?: true
Size: 748 Bytes
Versions: 13
Compression:
Stored size: 748 Bytes
Contents
module Eancom module Edifact class Message attr_accessor :items, :hash def initialize() @items = [] @hash = {} end def add_item(item) @items << item end 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 def to_json_hash message_hash = {} items_hash = { items: @items } message_hash.merge!(@hash) message_hash.merge!(items_hash) message_hash end private def group_name(segment) segment.group_name end end end end
Version data entries
13 entries across 13 versions & 1 rubygems