Class: ABNF::Parser::Rules::RegexpPattern
- Inherits:
-
Object
- Object
- ABNF::Parser::Rules::RegexpPattern
- Defined in:
- lib/abnf/parser/rules/regexp_pattern.rb
Instance Attribute Summary collapse
-
#abnf ⇒ Object
readonly
Returns the value of attribute abnf.
-
#max_octets ⇒ Object
readonly
Returns the value of attribute max_octets.
-
#regexp ⇒ Object
readonly
Returns the value of attribute regexp.
Instance Method Summary collapse
- #bounded_regexp ⇒ Object
- #call(io, _ = nil) ⇒ Object
-
#initialize(regexp, abnf, max_octets) ⇒ RegexpPattern
constructor
A new instance of RegexpPattern.
Constructor Details
#initialize(regexp, abnf, max_octets) ⇒ RegexpPattern
Returns a new instance of RegexpPattern.
9 10 11 12 13 |
# File 'lib/abnf/parser/rules/regexp_pattern.rb', line 9 def initialize regexp, abnf, max_octets @abnf = abnf @max_octets = max_octets @regexp = regexp end |
Instance Attribute Details
#abnf ⇒ Object (readonly)
Returns the value of attribute abnf.
5 6 7 |
# File 'lib/abnf/parser/rules/regexp_pattern.rb', line 5 def abnf @abnf end |
#max_octets ⇒ Object (readonly)
Returns the value of attribute max_octets.
6 7 8 |
# File 'lib/abnf/parser/rules/regexp_pattern.rb', line 6 def max_octets @max_octets end |
#regexp ⇒ Object (readonly)
Returns the value of attribute regexp.
7 8 9 |
# File 'lib/abnf/parser/rules/regexp_pattern.rb', line 7 def regexp @regexp end |
Instance Method Details
#bounded_regexp ⇒ Object
15 16 17 |
# File 'lib/abnf/parser/rules/regexp_pattern.rb', line 15 def bounded_regexp @bounded_regexp ||= %r{\A#{regexp}} end |
#call(io, _ = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/abnf/parser/rules/regexp_pattern.rb', line 19 def call io, _=nil string = io.read max_octets return unless string io.seek -string.bytesize, IO::SEEK_CUR match_data = bounded_regexp.match string if match_data node = Node.pattern_match match_data, abnf io.seek node.octets, IO::SEEK_CUR node end end |