Class: James::Markers::Current

Inherits:
Marker
  • Object
show all
Defined in:
lib/james/markers/current.rb

Overview

The visitor knows where in the conversation we are.

Instance Attribute Summary

Attributes inherited from Marker

#current

Instance Method Summary collapse

Methods inherited from Marker

#chainable?, #check, #enter, #exit, #hears?, #initialize, #process, #reset, #to_s, #transition

Constructor Details

This class inherits a constructor from James::Markers::Marker

Instance Method Details

#current?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/james/markers/current.rb', line 26

def current?
  true
end

#expectsObject

Expects all phrases, not just internal.



22
23
24
# File 'lib/james/markers/current.rb', line 22

def expects
  current.expects
end

#hear(phrase, &block) ⇒ Object

Hear a phrase.

Returns a new marker and self if it crossed a boundary. Returns itself if not.



14
15
16
17
18
# File 'lib/james/markers/current.rb', line 14

def hear phrase, &block
  return [self] unless hears? phrase
  last = current
  process(phrase, &block) ? [Memory.new(last), self] : [self]
end