Class: DZero::Transmissions::Base
- Inherits:
-
Object
- Object
- DZero::Transmissions::Base
- Extended by:
- Concerns::Parser
- Includes:
- Concerns::SegmentsMethods, Concerns::Serializer
- Defined in:
- lib/dzero/transmissions/base.rb
Constant Summary
Constants included from Concerns::SegmentsMethods
Concerns::SegmentsMethods::TRANSACTION_LEVEL_SEGMENTS, Concerns::SegmentsMethods::TRANSMISSION_LEVEL_SEGMENTS
Instance Attribute Summary collapse
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#transaction_groups ⇒ Object
readonly
Returns the value of attribute transaction_groups.
-
#transmission_group ⇒ Object
readonly
Returns the value of attribute transmission_group.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(header: {}, transmission_group: Groups::TransmissionGroup.new, transaction_groups: [], segments: []) ⇒ Base
constructor
A new instance of Base.
- #to_s ⇒ Object
Methods included from Concerns::Parser
Methods included from Concerns::Serializer
Methods included from Concerns::SegmentsMethods
#get_segment, included, #segments, #sort_segments
Constructor Details
#initialize(header: {}, transmission_group: Groups::TransmissionGroup.new, transaction_groups: [], segments: []) ⇒ Base
Returns a new instance of Base.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dzero/transmissions/base.rb', line 18 def initialize( header: {}, transmission_group: Groups::TransmissionGroup.new, transaction_groups: [], segments: [] ) @header = header @transmission_group = transmission_group @transaction_groups = transaction_groups unless segments.empty? sort_segments(segments) end end |
Instance Attribute Details
#header ⇒ Object (readonly)
Returns the value of attribute header.
33 34 35 |
# File 'lib/dzero/transmissions/base.rb', line 33 def header @header end |
#transaction_groups ⇒ Object (readonly)
Returns the value of attribute transaction_groups.
33 34 35 |
# File 'lib/dzero/transmissions/base.rb', line 33 def transaction_groups @transaction_groups end |
#transmission_group ⇒ Object (readonly)
Returns the value of attribute transmission_group.
33 34 35 |
# File 'lib/dzero/transmissions/base.rb', line 33 def transmission_group @transmission_group end |
Class Method Details
.header_schema ⇒ Object
13 14 15 |
# File 'lib/dzero/transmissions/base.rb', line 13 def header_schema raise NotImplementedError end |
Instance Method Details
#to_s ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/dzero/transmissions/base.rb', line 35 def to_s string = ::DZero::Utils::FixedWidth.to_fixed_width(header.slice(*self.class.header_schema.keys), self.class.header_schema) string += ::DZero::Constants::SEGMENT_SEPARATOR string += transmission_group.to_s string += transaction_groups.map(&:to_s).join string end |