Class: Eancom::Edifact::Document
- Inherits:
-
Object
- Object
- Eancom::Edifact::Document
- Defined in:
- lib/eancom/edifact/document.rb
Instance Attribute Summary collapse
-
#body_element ⇒ Object
Returns the value of attribute body_element.
-
#footer_element ⇒ Object
Returns the value of attribute footer_element.
-
#header_element ⇒ Object
Returns the value of attribute header_element.
Instance Method Summary collapse
- #add_to_body(segment) ⇒ Object
- #add_to_footer(segment) ⇒ Object
- #add_to_header(segment) ⇒ Object
- #body {|@body_element| ... } ⇒ Object
- #footer {|@footer_element| ... } ⇒ Object
- #header {|@header_element| ... } ⇒ Object
-
#initialize ⇒ Document
constructor
A new instance of Document.
- #to_json ⇒ Object
- #to_s(debug: false) ⇒ Object
-
#total_segments ⇒ Object
Should header and footer segments be added to total_segments?.
Constructor Details
Instance Attribute Details
#body_element ⇒ Object
Returns the value of attribute body_element.
5 6 7 |
# File 'lib/eancom/edifact/document.rb', line 5 def body_element @body_element end |
#footer_element ⇒ Object
Returns the value of attribute footer_element.
5 6 7 |
# File 'lib/eancom/edifact/document.rb', line 5 def @footer_element end |
#header_element ⇒ Object
Returns the value of attribute header_element.
5 6 7 |
# File 'lib/eancom/edifact/document.rb', line 5 def header_element @header_element end |
Instance Method Details
#add_to_body(segment) ⇒ Object
29 30 31 |
# File 'lib/eancom/edifact/document.rb', line 29 def add_to_body(segment) @body_element.segment(segment) end |
#add_to_footer(segment) ⇒ Object
33 34 35 |
# File 'lib/eancom/edifact/document.rb', line 33 def (segment) @footer_element.segment(segment) end |
#add_to_header(segment) ⇒ Object
25 26 27 |
# File 'lib/eancom/edifact/document.rb', line 25 def add_to_header(segment) @header_element.segment(segment) end |
#body {|@body_element| ... } ⇒ Object
17 18 19 |
# File 'lib/eancom/edifact/document.rb', line 17 def body(&block) yield(@body_element) end |
#footer {|@footer_element| ... } ⇒ Object
21 22 23 |
# File 'lib/eancom/edifact/document.rb', line 21 def (&block) yield(@footer_element) end |
#header {|@header_element| ... } ⇒ Object
13 14 15 |
# File 'lib/eancom/edifact/document.rb', line 13 def header(&block) yield(@header_element) end |
#to_json ⇒ Object
52 53 54 55 56 57 |
# 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) ⇒ Object
44 45 46 47 48 49 50 |
# 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 ⇒ Object
Should header and footer segments be added to total_segments?
38 39 40 41 42 |
# File 'lib/eancom/edifact/document.rb', line 38 def total_segments total = 0 total += @body_element.segments.count total end |