Class: Stupidedi::Reader::CompositeElementTok
- Inherits:
-
Object
- Object
- Stupidedi::Reader::CompositeElementTok
- Includes:
- Inspect
- Defined in:
- lib/stupidedi/reader/tokens/composite_element_tok.rb
Instance Attribute Summary collapse
- #component_toks ⇒ Array<ComponentElementTok> readonly
- #position ⇒ Position readonly
- #remainder ⇒ Position readonly
Constructors collapse
Instance Method Summary collapse
- #blank? ⇒ Boolean
- #composite? ⇒ Boolean
- #copy(changes = {}) ⇒ CompositeElementTok
-
#initialize(component_toks, position, remainder) ⇒ CompositeElementTok
constructor
A new instance of CompositeElementTok.
- #present? ⇒ Boolean
-
#pretty_print(q)
:nocov:.
-
#repeated
:nocov:.
- #repeated? ⇒ Boolean
- #simple? ⇒ Boolean
- #to_x12(separators)
Methods included from Inspect
Constructor Details
#initialize(component_toks, position, remainder) ⇒ CompositeElementTok
Returns a new instance of CompositeElementTok.
18 19 20 21 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 18 def initialize(component_toks, position, remainder) @component_toks, @position, @remainder = component_toks, position, remainder end |
Instance Attribute Details
#component_toks ⇒ Array<ComponentElementTok> (readonly)
10 11 12 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 10 def component_toks @component_toks end |
#position ⇒ Position (readonly)
13 14 15 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 13 def position @position end |
#remainder ⇒ Position (readonly)
16 17 18 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 16 def remainder @remainder end |
Class Method Details
.build(component_toks, position, remainder) ⇒ CompositeElementTok
77 78 79 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 77 def build(component_toks, position, remainder) new(component_toks, position, remainder) end |
Instance Method Details
#blank? ⇒ Boolean
45 46 47 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 45 def blank? @component_toks.all?(&:blank?) end |
#composite? ⇒ Boolean
57 58 59 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 57 def composite? true end |
#copy(changes = {}) ⇒ CompositeElementTok
24 25 26 27 28 29 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 24 def copy(changes = {}) CompositeElementTok.new \ changes.fetch(:component_toks, @component_toks), changes.fetch(:position, @position), changes.fetch(:remainder, @remainder) end |
#present? ⇒ Boolean
49 50 51 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 49 def present? not blank? end |
#pretty_print(q)
:nocov:
32 33 34 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 32 def pretty_print(q) q.pp(:composite.cons(@component_toks)) end |
#repeated
:nocov:
37 38 39 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 37 def repeated RepeatedElementTok.new(self.cons, @position) end |
#repeated? ⇒ Boolean
41 42 43 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 41 def repeated? false end |
#simple? ⇒ Boolean
53 54 55 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 53 def simple? false end |
#to_x12(separators)
61 62 63 64 65 66 67 68 69 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 61 def to_x12(separators) if blank? "" else cs = @component_toks.map{|x| x.to_x12(separators) } sep = separators.component || ":" cs.join(sep).gsub(/#{Regexp.escape(sep)}+$/, "") end end |