Class: Stupidedi::Reader::ComponentElementTok

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

Instance Attribute Summary collapse

Constructors collapse

Instance Method Summary collapse

Methods included from Inspect

#inspect

Constructor Details

#initialize(value, position, remainder) ⇒ ComponentElementTok

Returns a new instance of ComponentElementTok.



18
19
20
21
# File 'lib/stupidedi/reader/tokens/component_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/component_element_tok.rb', line 13

def position
  @position
end

#remainderPosition (readonly)

Returns:



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

def remainder
  @remainder
end

#valueString (readonly)

Returns:

  • (String)


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

def value
  @value
end

Class Method Details

.build(value, position, remainder) ⇒ ComponentElementTok

Returns:



63
64
65
# File 'lib/stupidedi/reader/tokens/component_element_tok.rb', line 63

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

Instance Method Details

#blank?Boolean

:nocov:

Returns:

  • (Boolean)


37
38
39
# File 'lib/stupidedi/reader/tokens/component_element_tok.rb', line 37

def blank?
  @value.blank?
end

#composite?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/stupidedi/reader/tokens/component_element_tok.rb', line 49

def composite?
  false
end

#copy(changes = {}) ⇒ CompositeElementTok

Returns:



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

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

#present?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/stupidedi/reader/tokens/component_element_tok.rb', line 41

def present?
  not blank?
end

#pretty_print(q)

:nocov:



32
33
34
# File 'lib/stupidedi/reader/tokens/component_element_tok.rb', line 32

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

#simple?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/stupidedi/reader/tokens/component_element_tok.rb', line 45

def simple?
  true
end

#to_x12(separators)



53
54
55
# File 'lib/stupidedi/reader/tokens/component_element_tok.rb', line 53

def to_x12(separators)
  @value.to_s
end