Class: Stupidedi::Reader::RepeatedElementTok

Inherits:
Object
  • Object
show all
Includes:
Inspect
Defined in:
lib/stupidedi/reader/tokens/repeated_element_tok.rb

Instance Attribute Summary collapse

Constructors collapse

Instance Method Summary collapse

Methods included from Inspect

#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_toksArray<CompositeElementTok>, Array<SimpleElementTok> (readonly)

Returns:



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

Returns:



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

Returns:

  • (Boolean)


39
40
41
# File 'lib/stupidedi/reader/tokens/repeated_element_tok.rb', line 39

def blank?
  @element_toks.all?(&:blank?)
end

#composite?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/stupidedi/reader/tokens/repeated_element_tok.rb', line 47

def composite?
  false
end

#present?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


35
36
37
# File 'lib/stupidedi/reader/tokens/repeated_element_tok.rb', line 35

def repeated?
  true
end

#simple?Boolean

Returns:

  • (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