Class: Sexpr::Matcher::Terminal

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

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

#inspectObject



12
13
14
# File 'lib/sexpr/matcher/terminal.rb', line 12

def inspect
  "(terminal #{value.inspect})"
end

#match?(sexp) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/sexpr/matcher/terminal.rb', line 16

def match?(sexp)
  terminal_match?(sexp)
end