class Woyo::Way
Public Instance Methods
close!()
click to toggle source
# File lib/woyo/world/way.rb, line 31 def close! closed! end
from()
click to toggle source
# File lib/woyo/world/way.rb, line 35 def from @from ||= context end
initialize_object()
click to toggle source
Calls superclass method
# File lib/woyo/world/way.rb, line 7 def initialize_object super attribute :going exclusion :passable, :closed, :open # defaults to closed: true action :go do describe proc { self.context.going } #result proc { self.context.passable } execution do { go: open?, location: open? ? self.to.id : nil } end end end
to(arg=nil)
click to toggle source
# File lib/woyo/world/way.rb, line 39 def to arg=nil if arg.nil? @to else self.to = arg end end
to=(arg)
click to toggle source
# File lib/woyo/world/way.rb, line 47 def to= arg if arg.instance_of? Symbol case when from && arg == from.id @to = from # way loops back to the same location when world && world.locations[arg] @to = world.locations[arg] # destination location already exists in world when world @to = world.location arg # create destination location in world else @to = Location.new arg # create free-standing destination location end self.open! else raise "Symbol required, but #{arg.class} : '#{arg}' given." end end
world()
click to toggle source
def go
{ go: open?, going: self.going }
end
# File lib/woyo/world/way.rb, line 27 def world from ? from.world : nil end