Class: Stupidedi::Values::LoopVal
Overview
Instance Attribute Summary collapse
Instance Method Summary
collapse
#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
19
20
21
|
# File 'lib/stupidedi/values/loop_val.rb', line 19
def children
@children
end
|
#definition ⇒ LoopDef
14
15
16
|
# File 'lib/stupidedi/values/loop_val.rb', line 14
def definition
@definition
end
|
Instance Method Details
#==(other) ⇒ 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
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
|
#inspect ⇒ String
61
62
63
|
# File 'lib/stupidedi/values/loop_val.rb', line 61
def inspect
ansi.loop("Loop") + "(#{@children.map(&:inspect).join(", ")})"
end
|
#loop?
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
|