Class: ABNF::Parser::Node::Sequence
- Inherits:
-
Object
- Object
- ABNF::Parser::Node::Sequence
show all
- Includes:
- ABNF::Parser::Node, Enumerable
- Defined in:
- lib/abnf/parser/node.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#==, alternation, concatenation, #octets, pattern_match, repetition, terminal
Constructor Details
#initialize(children, abnf) ⇒ Sequence
Returns a new instance of Sequence.
58
59
60
61
|
# File 'lib/abnf/parser/node.rb', line 58
def initialize children, abnf
@abnf = abnf
@children = children
end
|
Instance Attribute Details
#abnf ⇒ Object
Returns the value of attribute abnf.
55
56
57
|
# File 'lib/abnf/parser/node.rb', line 55
def abnf
@abnf
end
|
#children ⇒ Object
Returns the value of attribute children.
56
57
58
|
# File 'lib/abnf/parser/node.rb', line 56
def children
@children
end
|
Instance Method Details
#[](index) ⇒ Object
63
64
65
|
# File 'lib/abnf/parser/node.rb', line 63
def [] index
children[index]
end
|
#add(child) ⇒ Object
Also known as:
<<
67
68
69
|
# File 'lib/abnf/parser/node.rb', line 67
def add child
children << child
end
|
#child_count ⇒ Object
72
73
74
|
# File 'lib/abnf/parser/node.rb', line 72
def child_count
children.size
end
|
#each(&block) ⇒ Object
76
77
78
|
# File 'lib/abnf/parser/node.rb', line 76
def each &block
children.each &block
end
|
#text ⇒ Object
80
81
82
|
# File 'lib/abnf/parser/node.rb', line 80
def text
@text ||= to_a.join
end
|
#to_a ⇒ Object
84
85
86
87
88
89
90
91
92
|
# File 'lib/abnf/parser/node.rb', line 84
def to_a
map do |child|
if child.respond_to? :to_a
child.to_a
else
child.text
end
end
end
|