Class: Generated::MatchRule

Inherits:
Rule
  • Object
show all
Defined in:
lib/ruby_grammar_builder/generated/rule.rb

Instance Attribute Summary collapse

Attributes inherited from Rule

#location

Instance Method Summary collapse

Constructor Details

#initialize(location) ⇒ MatchRule

Returns a new instance of MatchRule.



72
73
74
# File 'lib/ruby_grammar_builder/generated/rule.rb', line 72

def initialize(location)
    super(location)
end

Instance Attribute Details

#capturesHash<String=>Rule>

Returns The capture rules.

Returns:



70
71
72
# File 'lib/ruby_grammar_builder/generated/rule.rb', line 70

def captures
  @captures
end

#matchString

Returns The match pattern.

Returns:

  • (String)

    The match pattern



66
67
68
# File 'lib/ruby_grammar_builder/generated/rule.rb', line 66

def match
  @match
end

#nameString?

Returns The name for this rule.

Returns:

  • (String, nil)

    The name for this rule



68
69
70
# File 'lib/ruby_grammar_builder/generated/rule.rb', line 68

def name
  @name
end

Instance Method Details

#to_hObject



76
77
78
79
80
81
82
# File 'lib/ruby_grammar_builder/generated/rule.rb', line 76

def to_h
    {
        "match" => @match,
        "name" => @name,
        "captures" => @captures.transform_values(&:to_h),
    }.compact
end