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, #child_count, #children, concatenation, #each, #octets, pattern_match, repetition, terminal

Constructor Details

#initialize(match_data, abnf) ⇒ PatternMatch



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

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

Instance Attribute Details

#abnfObject (readonly)

Returns the value of attribute abnf.



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

def abnf
  @abnf
end

#match_dataObject (readonly)

Returns the value of attribute match_data.



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

def match_data
  @match_data
end

Instance Method Details

#patternObject



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

def pattern
  match_data.regexp
end

#textObject



126
127
128
# File 'lib/abnf/parser/node.rb', line 126

def text
  match_data.to_s
end

#to_hObject



130
131
132
133
134
135
136
137
138
# File 'lib/abnf/parser/node.rb', line 130

def to_h
  hash = {}

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

  hash
end