Class: ABNF::Parser::Rules::Terminal
- Inherits:
-
Object
- Object
- ABNF::Parser::Rules::Terminal
- Defined in:
- lib/abnf/parser/rules/terminal.rb
Direct Known Subclasses
Defined Under Namespace
Classes: CharacterRange, String
Instance Attribute Summary collapse
-
#abnf ⇒ Object
readonly
Returns the value of attribute abnf.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other_rule) ⇒ Object
- #call(io, _ = nil) ⇒ Object
-
#initialize(pattern, abnf) ⇒ Terminal
constructor
A new instance of Terminal.
Constructor Details
Instance Attribute Details
#abnf ⇒ Object (readonly)
Returns the value of attribute abnf.
5 6 7 |
# File 'lib/abnf/parser/rules/terminal.rb', line 5 def abnf @abnf end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
6 7 8 |
# File 'lib/abnf/parser/rules/terminal.rb', line 6 def pattern @pattern end |
Class Method Details
.character_range(*arguments) ⇒ Object
57 58 59 |
# File 'lib/abnf/parser/rules/terminal.rb', line 57 def self.character_range *arguments CharacterRange.new *arguments end |
Instance Method Details
#==(other_rule) ⇒ Object
14 15 16 17 |
# File 'lib/abnf/parser/rules/terminal.rb', line 14 def == other_rule return false unless other_rule.is_a? self.class pattern == other_rule.pattern end |
#call(io, _ = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/abnf/parser/rules/terminal.rb', line 19 def call io, _=nil potential_match = io.read octets return unless potential_match matches = match? potential_match if matches Node.terminal potential_match, abnf else io.seek -potential_match.bytesize, IO::SEEK_CUR nil end end |