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(_obj = nil) ⇒ Object
- #to_s(debug: false) ⇒ Object
- #total_segments ⇒ Object
Constructor Details
Instance Attribute Details
#body_element ⇒ Object
Returns the value of attribute body_element.
6 7 8 |
# File 'lib/eancom/edifact/document.rb', line 6 def body_element @body_element end |
#footer_element ⇒ Object
Returns the value of attribute footer_element.
6 7 8 |
# File 'lib/eancom/edifact/document.rb', line 6 def @footer_element end |
#header_element ⇒ Object
Returns the value of attribute header_element.
6 7 8 |
# File 'lib/eancom/edifact/document.rb', line 6 def header_element @header_element end |
Instance Method Details
#add_to_body(segment) ⇒ Object
30 31 32 |
# File 'lib/eancom/edifact/document.rb', line 30 def add_to_body(segment) @body_element.segment(segment) end |
#add_to_footer(segment) ⇒ Object
34 35 36 |
# File 'lib/eancom/edifact/document.rb', line 34 def (segment) @footer_element.segment(segment) end |
#add_to_header(segment) ⇒ Object
26 27 28 |
# File 'lib/eancom/edifact/document.rb', line 26 def add_to_header(segment) @header_element.segment(segment) end |
#body {|@body_element| ... } ⇒ Object
18 19 20 |
# File 'lib/eancom/edifact/document.rb', line 18 def body yield(@body_element) end |
#footer {|@footer_element| ... } ⇒ Object
22 23 24 |
# File 'lib/eancom/edifact/document.rb', line 22 def yield(@footer_element) end |
#header {|@header_element| ... } ⇒ Object
14 15 16 |
# File 'lib/eancom/edifact/document.rb', line 14 def header yield(@header_element) end |
#to_json(_obj = nil) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/eancom/edifact/document.rb', line 48 def to_json(_obj = nil) { **@header_element.to_json_hash, **@body_element.to_json_hash }.to_json end |
#to_s(debug: false) ⇒ Object
44 45 46 |
# File 'lib/eancom/edifact/document.rb', line 44 def to_s(debug: false) "#{@header_element.to_s(debug: debug)}#{@body_element.to_s(debug: debug)}#{@footer_element.to_s(debug: debug)}" end |
#total_segments ⇒ Object
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 |