class CoopAl::PathFollower
Attributes
state[R]
Public Class Methods
new(library, starting_state)
click to toggle source
# File lib/coop_al/path_follower.rb, line 8 def initialize(library, starting_state) @library = library @state = starting_state end
Public Instance Methods
follow(paths, log)
click to toggle source
# File lib/coop_al/path_follower.rb, line 13 def follow(paths, log) paths.each do |path| follow_path(path, log) end @state end
Private Instance Methods
follow_path(path, log)
click to toggle source
# File lib/coop_al/path_follower.rb, line 22 def follow_path(path, log) if path.root? log.record_downtime(@library.resolve(@state.current_path).adventure_name) @state.apply_path(path) else raise Exception, "#{path} not a valid next path" unless @library.path?(@state.current_path + path) raise Exception, "Cannot repeat path (#{path})" if @state.history_includes?(@state.current_path + path) @state.apply_path(path) @library.resolve(@state.current_path).follow(@state, log) end end