Class: ABNF::Parser::Node::Sequence
- Inherits:
-
Object
- Object
- ABNF::Parser::Node::Sequence
- Includes:
- ABNF::Parser::Node, Enumerable
- Defined in:
- lib/abnf/parser/node.rb
Instance Attribute Summary collapse
-
#abnf ⇒ Object
readonly
Returns the value of attribute abnf.
-
#children ⇒ Object
readonly
Returns the value of attribute children.
Instance Method Summary collapse
- #add(child) ⇒ Object (also: #<<)
-
#initialize(children, abnf) ⇒ Sequence
constructor
A new instance of Sequence.
- #text ⇒ Object
- #to_a ⇒ Object
Methods included from ABNF::Parser::Node
#==, #[], alternation, #child_count, concatenation, #each, #octets, pattern_match, repetition, terminal
Constructor Details
#initialize(children, abnf) ⇒ Sequence
Returns a new instance of Sequence.
74 75 76 77 |
# File 'lib/abnf/parser/node.rb', line 74 def initialize children, abnf @abnf = abnf @children = children end |
Instance Attribute Details
#abnf ⇒ Object (readonly)
Returns the value of attribute abnf.
71 72 73 |
# File 'lib/abnf/parser/node.rb', line 71 def abnf @abnf end |
#children ⇒ Object (readonly)
Returns the value of attribute children.
72 73 74 |
# File 'lib/abnf/parser/node.rb', line 72 def children @children end |
Instance Method Details
#add(child) ⇒ Object Also known as: <<
79 80 81 |
# File 'lib/abnf/parser/node.rb', line 79 def add child children << child end |
#text ⇒ Object
84 85 86 |
# File 'lib/abnf/parser/node.rb', line 84 def text @text ||= to_a.join end |
#to_a ⇒ Object
88 89 90 91 92 93 94 95 96 |
# File 'lib/abnf/parser/node.rb', line 88 def to_a map do |child| if child.respond_to? :to_a child.to_a else child.text end end end |