Class: James::Markers::Memory

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

Overview

A marker is a point in conversation where we once were and might go back.

TODO: Rename to ?.

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



29
30
31
# File 'lib/james/markers/memory.rb', line 29

def current?
  false
end

#expectsObject

A marker does not care about phrases that cross dialog boundaries.



25
26
27
# File 'lib/james/markers/memory.rb', line 25

def expects
  current.internal_expects
end

#hear(phrase, &block) ⇒ Object

Hear a phrase.

Returns a new Current if it heard. Returns itself if not.



17
18
19
20
21
# File 'lib/james/markers/memory.rb', line 17

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