Class: Sexpr::Matcher::Rule
- Inherits:
-
Object
- Object
- Sexpr::Matcher::Rule
- Includes:
- Sexpr::Matcher
- Defined in:
- lib/sexpr/matcher/rule.rb
Instance Attribute Summary collapse
-
#defn ⇒ Object
readonly
Returns the value of attribute defn.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #eat(sexp) ⇒ Object
-
#initialize(name, defn) ⇒ Rule
constructor
A new instance of Rule.
- #inspect ⇒ Object
- #match?(sexp) ⇒ Boolean
Methods included from Sexpr::Matcher
Constructor Details
#initialize(name, defn) ⇒ Rule
Returns a new instance of Rule.
9 10 11 12 |
# File 'lib/sexpr/matcher/rule.rb', line 9 def initialize(name, defn) @name = name @defn = defn end |
Instance Attribute Details
#defn ⇒ Object (readonly)
Returns the value of attribute defn.
7 8 9 |
# File 'lib/sexpr/matcher/rule.rb', line 7 def defn @defn end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/sexpr/matcher/rule.rb', line 6 def name @name end |
Instance Method Details
#eat(sexp) ⇒ Object
18 19 20 |
# File 'lib/sexpr/matcher/rule.rb', line 18 def eat(sexp) defn.eat(sexp) end |
#inspect ⇒ Object
22 23 24 |
# File 'lib/sexpr/matcher/rule.rb', line 22 def inspect "(rule #{name}, #{defn.inspect})" end |
#match?(sexp) ⇒ Boolean
14 15 16 |
# File 'lib/sexpr/matcher/rule.rb', line 14 def match?(sexp) defn.match?(sexp) end |