class Olib::Shop::Container
Attributes
cache[RW]
containers[RW]
id[RW]
nested[RW]
props[RW]
show[RW]
Public Class Methods
new(obj)
click to toggle source
Calls superclass method
Olib::Gameobj_Extender::new
# File lib/Olib/shops.rb, line 41 def initialize(obj) @cache = Hash.new @props = Hash.new super(obj) end
Public Instance Methods
action(verb)
click to toggle source
# File lib/Olib/shops.rb, line 47 def action(verb) "#{verb} ##{@id}" end
at()
click to toggle source
detect nested containers
# File lib/Olib/shops.rb, line 56 def at Olib.wrap_stream(action 'look at') { |line| raise Olib::Errors::Mundane if line =~ /You see nothing unusual/ if line =~ /Looking at the (.*?), you see (?<nested>.*)/ @nested = true @containers = line.match(/Looking at the (.*?), you see (?<nested>.*)/)[:nested].scan(/<a exist="(?<id>.*?)" noun="(?<noun>.*?)">(?<name>.*?)<\/a>/).map {|matches| Container.new GameObj.new *matches } raise Olib::Errors::Prempt end } self end
contents()
click to toggle source
# File lib/Olib/shops.rb, line 98 def contents look.in.on unless GameObj[@id].contents GameObj[@id].contents.map {|i| Item.new(i).define('container', @id) } end
in()
click to toggle source
# File lib/Olib/shops.rb, line 80 def in return self unless @id Olib.wrap_stream(action 'look in') { |line| raise Olib::Errors::Mundane if line=~ /^There is nothing in there|^That is closed|filled with a variety of garbage|Total items:/ raise Olib::Errors::Prempt if line =~ /^In the (.*?) you see/ } self end
look()
click to toggle source
# File lib/Olib/shops.rb, line 51 def look self end
nested?()
click to toggle source
# File lib/Olib/shops.rb, line 76 def nested? @nested || false end
on()
click to toggle source
# File lib/Olib/shops.rb, line 89 def on return self unless @id Olib.wrap_stream(action 'look on') { |line| raise Olib::Errors::Mundane if line =~ /^There is nothing on there/ raise Olib::Errors::Prempt if line =~ /^On the (.*?) you see/ } self end
to_s()
click to toggle source
# File lib/Olib/shops.rb, line 32 def to_s info = {} info[:name] = @name info[:noun] = @noun info[:props] = @props info[:cache] = @cache info.to_s end