Class: ABNF::Compiler::Rule::ValueRange
- Inherits:
-
Object
- Object
- ABNF::Compiler::Rule::ValueRange
- Includes:
- ABNF::Compiler::Rule
- Defined in:
- lib/abnf/compiler/rule/value_range.rb
Instance Attribute Summary collapse
-
#end_character ⇒ Object
readonly
Returns the value of attribute end_character.
-
#start_character ⇒ Object
readonly
Returns the value of attribute start_character.
Instance Method Summary collapse
-
#initialize(start_character, end_character) ⇒ ValueRange
constructor
A new instance of ValueRange.
- #parse(stream) ⇒ Object
- #regexp ⇒ Object
Methods included from ABNF::Compiler::Rule
Constructor Details
#initialize(start_character, end_character) ⇒ ValueRange
Returns a new instance of ValueRange.
10 11 12 13 |
# File 'lib/abnf/compiler/rule/value_range.rb', line 10 def initialize start_character, end_character @start_character = start_character @end_character = end_character end |
Instance Attribute Details
#end_character ⇒ Object (readonly)
Returns the value of attribute end_character.
8 9 10 |
# File 'lib/abnf/compiler/rule/value_range.rb', line 8 def end_character @end_character end |
#start_character ⇒ Object (readonly)
Returns the value of attribute start_character.
7 8 9 |
# File 'lib/abnf/compiler/rule/value_range.rb', line 7 def start_character @start_character end |
Instance Method Details
#parse(stream) ⇒ Object
15 16 17 18 19 |
# File 'lib/abnf/compiler/rule/value_range.rb', line 15 def parse stream match_data = stream.match regexp return unless match_data AST.leaf match_data.to_s end |
#regexp ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/abnf/compiler/rule/value_range.rb', line 21 def regexp @regexp ||= begin start_char = Regexp.escape start_character end_char = Regexp.escape end_character Regexp.new "[#{start_char}-#{end_char}]", false, 'n'.freeze end end |