Class: Olib::Gameobj_Extender

Inherits:
Object
  • Object
show all
Defined in:
lib/Olib/core/extender.rb

Direct Known Subclasses

Container, Item, Shop::Container

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item) ⇒ Gameobj_Extender


6
7
8
9
# File 'lib/Olib/core/extender.rb', line 6

def initialize(item)
  self.__extend__(item)
  @type = item.type
end

Instance Attribute Details

#typeObject

Returns the value of attribute type


5
6
7
# File 'lib/Olib/core/extender.rb', line 5

def type
  @type
end

Instance Method Details

#__extend__(item) ⇒ Object

This copies GameObj data to attributes so we can employ it for scripting


12
13
14
15
16
17
18
# File 'lib/Olib/core/extender.rb', line 12

def __extend__(item)
  item.instance_variables.each { |var|
    s = var.to_s.sub('@', '')
    (class << self; self end).class_eval do; attr_accessor "#{s}"; end
    instance_variable_set "#{var}", item.send(s)
  }
end

#atObject


25
26
27
# File 'lib/Olib/core/extender.rb', line 25

def at
  fput "look at ##{@id}"
end

#echoObject


20
21
22
23
# File 'lib/Olib/core/extender.rb', line 20

def echo
  respond self
  self
end