Class: Stupidedi::Reader::SimpleElementTok

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

Instance Attribute Summary collapse

Constructors collapse

Instance Method Summary collapse

Methods included from Inspect

#inspect

Constructor Details

#initialize(value, position, remainder) ⇒ SimpleElementTok

Returns a new instance of SimpleElementTok.


18
19
20
21
# File 'lib/stupidedi/reader/tokens/simple_element_tok.rb', line 18

def initialize(value, position, remainder)
  @value, @position, @remainder =
    value, position, remainder
end

Instance Attribute Details

#positionPosition (readonly)

Returns:


13
14
15
# File 'lib/stupidedi/reader/tokens/simple_element_tok.rb', line 13

def position
  @position
end

#remainderPosition (readonly)

Returns:


16
17
18
# File 'lib/stupidedi/reader/tokens/simple_element_tok.rb', line 16

def remainder
  @remainder
end

#valueString, Object (readonly)

Returns:

  • (String, Object)

10
11
12
# File 'lib/stupidedi/reader/tokens/simple_element_tok.rb', line 10

def value
  @value
end

Class Method Details

.build(value, position, remainder)


68
69
70
# File 'lib/stupidedi/reader/tokens/simple_element_tok.rb', line 68

def build(value, position, remainder)
  new(value, position, remainder)
end

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)

43
44
45
# File 'lib/stupidedi/reader/tokens/simple_element_tok.rb', line 43

def blank?
  @value.blank?
end

#composite?Boolean

Returns:

  • (Boolean)

55
56
57
# File 'lib/stupidedi/reader/tokens/simple_element_tok.rb', line 55

def composite?
  false
end

#copy(changes = {}) ⇒ SimpleElementTok

Returns:


24
25
26
27
28
29
# File 'lib/stupidedi/reader/tokens/simple_element_tok.rb', line 24

def copy(changes = {})
  SimpleElementTok.new \
    changes.fetch(:value, @value),
    changes.fetch(:position, @position),
    changes.fetch(:remainder, @remainder)
end

#present?Boolean

Returns:

  • (Boolean)

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

def present?
  not blank?
end

#pretty_print(q)


31
32
33
# File 'lib/stupidedi/reader/tokens/simple_element_tok.rb', line 31

def pretty_print(q)
  q.pp(:simple.cons(@value.cons))
end

#repeated


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

def repeated
  RepeatedElementTok.new(self.cons, @position)
end

#repeated?Boolean

Returns:

  • (Boolean)

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

def repeated?
  false
end

#simple?Boolean

Returns:

  • (Boolean)

51
52
53
# File 'lib/stupidedi/reader/tokens/simple_element_tok.rb', line 51

def simple?
  true
end

#to_x12(separators)


59
60
61
# File 'lib/stupidedi/reader/tokens/simple_element_tok.rb', line 59

def to_x12(separators)
  @value.to_s
end