Class: Area

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/Olib/area.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeArea

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

#autoidObject (readonly)

Returns the value of attribute autoid.



16
17
18
# File 'lib/Olib/area.rb', line 16

def autoid
  @autoid
end

#objectsObject (readonly)

Returns the value of attribute objects.



16
17
18
# File 'lib/Olib/area.rb', line 16

def objects
  @objects
end

#roomObject (readonly)

Returns the value of attribute room.



16
17
18
# File 'lib/Olib/area.rb', line 16

def room
  @room
end

Class Method Details

.method_missing(method, *args, &block) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/Olib/area.rb', line 3

def self.method_missing(method, *args, &block)
  if respond_to?(method)
    Area.new.send(method, *args, &block)
  else
    super(method, *args, &block)
  end
end

.respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
# File 'lib/Olib/area.rb', line 11

def self.respond_to?(method)
  return super(method) unless Area.new.respond_to?(method)
  return true
end

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

#deepObject



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