Class: Stupidedi::Values::LoopVal

Inherits:
AbstractVal show all
Includes:
SegmentValGroup
Defined in:
lib/stupidedi/values/loop_val.rb

Overview

See Also:

  • B.1.1.3.12.2 Data Segment Groups
  • B.1.1.3.12.4 Loops of Data Segments

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SegmentValGroup

#leaf?

Methods inherited from AbstractVal

#blank?, #characters, #component?, #composite?, #descriptor, #element?, #empty?, #functional_group?, #interchange?, #invalid?, #leaf?, #present?, #repeated?, #segment?, #separator?, #simple?, #size, #table?, #transaction_set?, #transmission?, #valid?

Methods included from Color

ansi, #ansi

Constructor Details

#initialize(definition, children) ⇒ LoopVal

Returns a new instance of LoopVal.



23
24
25
26
# File 'lib/stupidedi/values/loop_val.rb', line 23

def initialize(definition, children)
  @definition, @children =
    definition, children
end

Instance Attribute Details

#childrenArray<SegmentVal, LoopVal> (readonly)

Returns:



19
20
21
# File 'lib/stupidedi/values/loop_val.rb', line 19

def children
  @children
end

#definitionLoopDef (readonly)

Returns:

  • (LoopDef)


14
15
16
# File 'lib/stupidedi/values/loop_val.rb', line 14

def definition
  @definition
end

Instance Method Details

#==(other) ⇒ Boolean

Returns:

  • (Boolean)


66
67
68
69
70
# File 'lib/stupidedi/values/loop_val.rb', line 66

def ==(other)
  eql?(other) or
   (other.definition == @definition and
    other.children   == @children)
end

#copy(changes = {}) ⇒ LoopVal

Returns:



29
30
31
32
33
# File 'lib/stupidedi/values/loop_val.rb', line 29

def copy(changes = {})
  LoopVal.new \
    changes.fetch(:definition, @definition),
    changes.fetch(:children, @children)
end

#inspectString

Returns:

  • (String)


61
62
63
# File 'lib/stupidedi/values/loop_val.rb', line 61

def inspect
  ansi.loop("Loop") + "(#{@children.map(&:inspect).join(", ")})"
end

#loop?

Returns:

  • true



37
38
39
# File 'lib/stupidedi/values/loop_val.rb', line 37

def loop?
  true
end

#pretty_print(q)

This method returns an undefined value.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/stupidedi/values/loop_val.rb', line 42

def pretty_print(q)
  id = @definition.try do |d|
    ansi.bold("[#{d.id.to_s}]")
  end

  q.text(ansi.loop("LoopVal#{id}"))
  q.group(2, "(", ")") do
    q.breakable ""
    @children.each do |e|
      unless q.current_group.first?
        q.text ","
        q.breakable
      end
      q.pp e
    end
  end
end