Class: Sexpr::Matcher::Rule

Inherits:
Object
  • Object
show all
Includes:
Sexpr::Matcher
Defined in:
lib/sexpr/matcher/rule.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#defnObject (readonly)

Returns the value of attribute defn.



7
8
9
# File 'lib/sexpr/matcher/rule.rb', line 7

def defn
  @defn
end

#nameObject (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

#inspectObject



22
23
24
# File 'lib/sexpr/matcher/rule.rb', line 22

def inspect
  "(rule #{name}, #{defn.inspect})"
end

#match?(sexp) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/sexpr/matcher/rule.rb', line 14

def match?(sexp)
  defn.match?(sexp)
end