Class: Sexpr::Matcher::Terminal
- Inherits:
-
Object
- Object
- Sexpr::Matcher::Terminal
- Includes:
- Sexpr::Matcher
- Defined in:
- lib/sexpr/matcher/terminal.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #eat(sexp) ⇒ Object
-
#initialize(value) ⇒ Terminal
constructor
A new instance of Terminal.
- #inspect ⇒ Object
- #match?(sexp) ⇒ Boolean
Methods included from Sexpr::Matcher
Constructor Details
#initialize(value) ⇒ Terminal
Returns a new instance of Terminal.
8 9 10 |
# File 'lib/sexpr/matcher/terminal.rb', line 8 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
6 7 8 |
# File 'lib/sexpr/matcher/terminal.rb', line 6 def value @value end |
Instance Method Details
#eat(sexp) ⇒ Object
20 21 22 |
# File 'lib/sexpr/matcher/terminal.rb', line 20 def eat(sexp) match?(sexp.first) ? sexp[1..-1] : nil end |
#inspect ⇒ Object
12 13 14 |
# File 'lib/sexpr/matcher/terminal.rb', line 12 def inspect "(terminal #{value.inspect})" end |
#match?(sexp) ⇒ Boolean
16 17 18 |
# File 'lib/sexpr/matcher/terminal.rb', line 16 def match?(sexp) terminal_match?(sexp) end |