Class: Stupidedi::Reader::Separators
- Inherits:
-
Object
- Object
- Stupidedi::Reader::Separators
- Defined in:
- lib/stupidedi/reader/separators.rb
Overview
Stores the separators used to tokenize X12 from an input stream and serialize it to an output stream.
Instance Attribute Summary (collapse)
Constructors (collapse)
Instance Method Summary (collapse)
- - (AbstractSet<String>) characters
- - (Separators) copy(changes = {})
-
- (Separators) initialize(component, repetition, element, segment)
constructor
A new instance of Separators.
- - (String) inspect
-
- merge(other)
Creates a new value that has the separators from
other, when they are not nil, and will use separators fromselfotherwise.
Constructor Details
- (Separators) initialize(component, repetition, element, segment)
A new instance of Separators
24 25 26 27 |
# File 'lib/stupidedi/reader/separators.rb', line 24 def initialize(component, repetition, element, segment) @component, @repetition, @element, @segment = component, repetition, element, segment end |
Instance Attribute Details
- (String) component
13 14 15 |
# File 'lib/stupidedi/reader/separators.rb', line 13 def component @component end |
- (String) element
19 20 21 |
# File 'lib/stupidedi/reader/separators.rb', line 19 def element @element end |
- (String) repetition
16 17 18 |
# File 'lib/stupidedi/reader/separators.rb', line 16 def repetition @repetition end |
- (String) segment
22 23 24 |
# File 'lib/stupidedi/reader/separators.rb', line 22 def segment @segment end |
Class Method Details
+ (Separators) build(hash)
72 73 74 75 76 77 78 |
# File 'lib/stupidedi/reader/separators.rb', line 72 def build(hash) Separators.new \ hash[:component], hash[:repetition], hash[:element], hash[:segment] end |
+ (Separators) empty
67 68 69 |
# File 'lib/stupidedi/reader/separators.rb', line 67 def empty new(nil, nil, nil, nil) end |
Instance Method Details
- (AbstractSet<String>) characters
49 50 51 52 53 54 |
# File 'lib/stupidedi/reader/separators.rb', line 49 def characters chars = [@component, @repetition, @element, @segment].select(&:present?) Sets.absolute(chars.join.split(//), Reader::C_BYTES.split(//)) end |
- (Separators) copy(changes = {})
30 31 32 33 34 35 36 |
# File 'lib/stupidedi/reader/separators.rb', line 30 def copy(changes = {}) Separators.new \ changes.fetch(:component, @component), changes.fetch(:repetition, @repetition), changes.fetch(:element, @element), changes.fetch(:segment, @segment) end |
- (String) inspect
57 58 59 |
# File 'lib/stupidedi/reader/separators.rb', line 57 def inspect "Separators(#{@component.inspect}, #{@repetition.inspect}, #{@element.inspect}, #{@segment.inspect})" end |
- merge(other)
Creates a new value that has the separators from other, when they
are not nil, and will use separators from self otherwise.
40 41 42 43 44 45 46 |
# File 'lib/stupidedi/reader/separators.rb', line 40 def merge(other) Separators.new \ other.component || @component, other.repetition || @repetition, other.element || @element, other.segment || @segment end |