class Eancom::Edifact::Document
Attributes
body_element[RW]
header_element[RW]
Public Class Methods
new()
click to toggle source
# File lib/eancom/edifact/document.rb, line 7 def initialize @header_element = Header.new() @body_element = Body.new() @footer_element = Footer.new() end
Public Instance Methods
add_to_body(segment)
click to toggle source
# File lib/eancom/edifact/document.rb, line 29 def add_to_body(segment) @body_element.segment(segment) end
add_to_header(segment)
click to toggle source
# File lib/eancom/edifact/document.rb, line 25 def add_to_header(segment) @header_element.segment(segment) end
body() { |body_element| ... }
click to toggle source
# File lib/eancom/edifact/document.rb, line 17 def body(&block) yield(@body_element) end
header() { |header_element| ... }
click to toggle source
# File lib/eancom/edifact/document.rb, line 13 def header(&block) yield(@header_element) end
to_json()
click to toggle source
# File lib/eancom/edifact/document.rb, line 52 def to_json hash = {} hash.merge! @header_element.to_json_hash hash.merge! @body_element.to_json_hash hash.to_json end
to_s(debug: false)
click to toggle source
# File lib/eancom/edifact/document.rb, line 44 def to_s(debug: false) stream = '' stream << @header_element.to_s(debug: debug) stream << @body_element.to_s(debug: debug) stream << @footer_element.to_s(debug: debug) stream end
total_segments()
click to toggle source
Should header and footer segments be added to total_segments
?
# File lib/eancom/edifact/document.rb, line 38 def total_segments total = 0 total += @body_element.segments.count total end