Class: Area
Instance Attribute Summary collapse
-
#autoid ⇒ Object
readonly
Returns the value of attribute autoid.
-
#objects ⇒ Object
readonly
Returns the value of attribute objects.
-
#room ⇒ Object
readonly
Returns the value of attribute room.
Class Method Summary collapse
Instance Method Summary collapse
- #check_container(container) ⇒ Object
- #deep ⇒ Object
- #each(&block) ⇒ Object
-
#initialize ⇒ Area
constructor
A new instance of Area.
Constructor Details
#initialize ⇒ Area
Returns a new instance of Area.
18 19 20 21 22 |
# File 'lib/Olib/area.rb', line 18 def initialize @room = Room.current @auto = XMLData.room_count @objects = [ GameObj.loot, GameObj.room_desc ].map(&:to_a).flatten.compact.map(&:to_container) end |
Instance Attribute Details
#autoid ⇒ Object (readonly)
Returns the value of attribute autoid.
16 17 18 |
# File 'lib/Olib/area.rb', line 16 def autoid @autoid end |
#objects ⇒ Object (readonly)
Returns the value of attribute objects.
16 17 18 |
# File 'lib/Olib/area.rb', line 16 def objects @objects end |
#room ⇒ Object (readonly)
Returns the value of attribute room.
16 17 18 |
# File 'lib/Olib/area.rb', line 16 def room @room end |
Class Method Details
Instance Method Details
#check_container(container) ⇒ Object
51 52 53 54 55 |
# File 'lib/Olib/area.rb', line 51 def check_container(container) unless container.contents container.look.at.on end end |
#deep ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/Olib/area.rb', line 28 def deep items = [] @objects.reject { |container| container.name =~ /[A-Z][a-z]+ disk/ }.each { |container| check_container container item = Item.new container unless container.nested? container.contents.each { |item| item.container = container items << item } else container.containers.each do |nested| check_container nested nested.contents.each { |item| item.container = container items << item } end end } items.compact.each do |item| yield(item) end end |
#each(&block) ⇒ Object
24 25 26 |
# File 'lib/Olib/area.rb', line 24 def each(&block) @objects.each(&block) end |