Class: Generated::PatternRule

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

Overview

Represents a rule in the form of { patterns = (Ruleā€¦); }

Instance Attribute Summary collapse

Attributes inherited from Rule

#location

Instance Method Summary collapse

Constructor Details

#initialize(location, rules) ⇒ PatternRule

Returns a new instance of PatternRule.



54
55
56
57
# File 'lib/ruby_grammar_builder/generated/rule.rb', line 54

def initialize(location, rules)
    super(location)
    @rules = rules
end

Instance Attribute Details

#rulesArray<Rule>

Returns The list of rules.

Returns:

  • (Array<Rule>)

    The list of rules



52
53
54
# File 'lib/ruby_grammar_builder/generated/rule.rb', line 52

def rules
  @rules
end

Instance Method Details

#to_hObject



59
60
61
# File 'lib/ruby_grammar_builder/generated/rule.rb', line 59

def to_h
    {"patterns" => @rules.map(&:to_h)}
end