Class: ABNF::Parser::Node::PatternMatch

Inherits:
Object
  • Object
show all
Includes:
ABNF::Parser::Node
Defined in:
lib/abnf/parser/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ABNF::Parser::Node

#==, alternation, concatenation, #octets, pattern_match, repetition, terminal

Constructor Details

#initialize(match_data, abnf) ⇒ PatternMatch

Returns a new instance of PatternMatch.



113
114
115
116
# File 'lib/abnf/parser/node.rb', line 113

def initialize match_data, abnf
  @match_data = match_data
  @abnf = abnf
end

Instance Attribute Details

#abnfObject (readonly)

Returns the value of attribute abnf.



110
111
112
# File 'lib/abnf/parser/node.rb', line 110

def abnf
  @abnf
end

#match_dataObject (readonly)

Returns the value of attribute match_data.



111
112
113
# File 'lib/abnf/parser/node.rb', line 111

def match_data
  @match_data
end

Instance Method Details

#patternObject



118
119
120
# File 'lib/abnf/parser/node.rb', line 118

def pattern
  match_data.regexp
end

#textObject



122
123
124
# File 'lib/abnf/parser/node.rb', line 122

def text
  match_data.to_s
end

#to_hObject



126
127
128
129
130
131
132
133
134
# File 'lib/abnf/parser/node.rb', line 126

def to_h
  hash = {}

  match_data.names.each do |name|
    hash[name] = match_data[name]
  end

  hash
end