Class: Stupidedi::Reader::RepeatedElementTok
- Inherits:
-
Object
- Object
- Stupidedi::Reader::RepeatedElementTok
- Includes:
- Inspect
- Defined in:
- lib/stupidedi/reader/tokens/repeated_element_tok.rb
Instance Attribute Summary collapse
- #element_toks ⇒ Array<CompositeElementTok>, Array<SimpleElementTok> readonly
-
#position
readonly
Returns the value of attribute position.
Constructors collapse
Instance Method Summary collapse
- #blank? ⇒ Boolean
- #composite? ⇒ Boolean
-
#initialize(element_toks, position) ⇒ RepeatedElementTok
constructor
A new instance of RepeatedElementTok.
- #present? ⇒ Boolean
- #pretty_print(q)
- #repeated(element_tok)
- #repeated? ⇒ Boolean
- #simple? ⇒ Boolean
- #to_x12(separators)
Methods included from Inspect
Constructor Details
#initialize(element_toks, position) ⇒ RepeatedElementTok
Returns a new instance of RepeatedElementTok.
17 18 19 20 |
# File 'lib/stupidedi/reader/tokens/repeated_element_tok.rb', line 17 def initialize(element_toks, position) @element_toks, @position = element_toks, position end |
Instance Attribute Details
#element_toks ⇒ Array<CompositeElementTok>, Array<SimpleElementTok> (readonly)
11 12 13 |
# File 'lib/stupidedi/reader/tokens/repeated_element_tok.rb', line 11 def element_toks @element_toks end |
#position (readonly)
Returns the value of attribute position.
13 14 15 |
# File 'lib/stupidedi/reader/tokens/repeated_element_tok.rb', line 13 def position @position end |
Class Method Details
.build(element_toks, position) ⇒ RepeatedElementTok
66 67 68 |
# File 'lib/stupidedi/reader/tokens/repeated_element_tok.rb', line 66 def build(element_toks, position) new(element_toks, position) end |
Instance Method Details
#blank? ⇒ Boolean
39 40 41 |
# File 'lib/stupidedi/reader/tokens/repeated_element_tok.rb', line 39 def blank? @element_toks.all?(&:blank?) end |
#composite? ⇒ Boolean
47 48 49 |
# File 'lib/stupidedi/reader/tokens/repeated_element_tok.rb', line 47 def composite? false end |
#present? ⇒ Boolean
43 44 45 |
# File 'lib/stupidedi/reader/tokens/repeated_element_tok.rb', line 43 def present? not blank? end |
#pretty_print(q)
27 28 29 |
# File 'lib/stupidedi/reader/tokens/repeated_element_tok.rb', line 27 def pretty_print(q) q.pp(:repeated.cons(@element_toks)) end |
#repeated(element_tok)
22 23 24 25 |
# File 'lib/stupidedi/reader/tokens/repeated_element_tok.rb', line 22 def repeated(element_tok) @element_toks.unshift(element_tok) self end |
#repeated? ⇒ Boolean
35 36 37 |
# File 'lib/stupidedi/reader/tokens/repeated_element_tok.rb', line 35 def repeated? true end |
#simple? ⇒ Boolean
31 32 33 |
# File 'lib/stupidedi/reader/tokens/repeated_element_tok.rb', line 31 def simple? false end |
#to_x12(separators)
51 52 53 54 55 56 57 58 |
# File 'lib/stupidedi/reader/tokens/repeated_element_tok.rb', line 51 def to_x12(separators) if blank? "" else rs = @element_toks.map{|x| x.to_x12(separators) } rs.join(separators.repetition || "^") end end |