Class: Stupidedi::Values::RepeatedElementVal
Overview
Instance Attribute Summary collapse
Instance Method Summary
collapse
#element?, #size
Methods inherited from AbstractVal
#blank?, #characters, #component?, #composite?, #definition, #element?, #functional_group?, #interchange?, #invalid?, #loop?, #present?, #segment?, #separator?, #simple?, #size, #table?, #transaction_set?, #transmission?, #valid?
Methods included from Color
ansi, #ansi
Methods included from Inspect
#inspect
Constructor Details
Returns a new instance of RepeatedElementVal.
23
24
25
26
|
# File 'lib/stupidedi/values/repeated_element_val.rb', line 23
def initialize(children, usage)
@children, @usage =
children, usage
end
|
Instance Attribute Details
15
16
17
|
# File 'lib/stupidedi/values/repeated_element_val.rb', line 15
def children
@children
end
|
Returns Schema::SimpleElementUse, Schema::CompositeElementUse.
19
20
21
|
# File 'lib/stupidedi/values/repeated_element_val.rb', line 19
def usage
@usage
end
|
Class Method Details
103
104
105
|
# File 'lib/stupidedi/values/repeated_element_val.rb', line 103
def build(children, element_use)
RepeatedElementVal.new(children, element_use)
end
|
98
99
100
|
# File 'lib/stupidedi/values/repeated_element_val.rb', line 98
def empty(element_use)
RepeatedElementVal.new([], element_use)
end
|
Instance Method Details
#==(other) ⇒ Boolean
86
87
88
89
90
|
# File 'lib/stupidedi/values/repeated_element_val.rb', line 86
def ==(other)
eql?(other)
(other.definition == definition and
other.children == @children)
end
|
29
30
31
32
33
|
# File 'lib/stupidedi/values/repeated_element_val.rb', line 29
def copy(changes = {})
RepeatedElementVal.new \
changes.fetch(:children, @children),
changes.fetch(:usage, @usage)
end
|
#element(n, o = nil) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/stupidedi/values/repeated_element_val.rb', line 50
def element(n, o = nil)
unless n > 0
raise ArgumentError,
"n must be positive"
end
unless o.nil?
@children.at(n - 1).element(o)
else
@children.at(n - 1)
end
end
|
#empty? ⇒ Boolean
46
47
48
|
# File 'lib/stupidedi/values/repeated_element_val.rb', line 46
def empty?
@children.empty? or @children.all?(&:empty?)
end
|
#leaf? ⇒ Boolean
36
37
38
|
# File 'lib/stupidedi/values/repeated_element_val.rb', line 36
def leaf?
false
end
|
#pretty_print(q) ⇒ void
This method returns an undefined value.
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/stupidedi/values/repeated_element_val.rb', line 64
def pretty_print(q)
if @children.empty?
id = definition.try do |d|
ansi.bold("[#{d.id.to_s}: #{d.name.to_s}]")
end
q.text(ansi.repeated("RepeatedElementVal#{id}"))
else
q.text(ansi.repeated("RepeatedElementVal"))
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
end
|
#repeated? ⇒ Boolean
41
42
43
|
# File 'lib/stupidedi/values/repeated_element_val.rb', line 41
def repeated?
true
end
|