Class: Edoors::Iota

Inherits:
Object
  • Object
show all
Defined in:
lib/edoors/iota.rb

Direct Known Subclasses

Door, Room

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(n, p) ⇒ Iota

creates a Iota object from the arguments.

Parameters:

  • n (String)

    the name of this Iota

  • p (Iota)

    the parent

See Also:



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/edoors/iota.rb', line 36

def initialize n, p
    raise Edoors::Exception.new "Iota name #{n} is not valid" if n.include? Edoors::PATH_SEP
    @name   = n     # unique in it's room
    @parent = p     # single direct parent
    @viewer = nil   # particle going through that position will be sent there readonly
    @path = ( @parent ? @parent.path+Edoors::PATH_SEP : '') + @name
    @spin = ( @parent ? @parent.spin : self )
    if @parent
        @parent.add_iota self
        @spin.add_to_world self if @spin.is_a? Edoors::Spin
    end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



49
50
51
# File 'lib/edoors/iota.rb', line 49

def name
  @name
end

#parentObject

Returns the value of attribute parent.



50
51
52
# File 'lib/edoors/iota.rb', line 50

def parent
  @parent
end

#pathObject (readonly)

Returns the value of attribute path.



49
50
51
# File 'lib/edoors/iota.rb', line 49

def path
  @path
end

#spinObject (readonly)

Returns the value of attribute spin.



49
50
51
# File 'lib/edoors/iota.rb', line 49

def spin
  @spin
end

#viewerObject

Returns the value of attribute viewer.



50
51
52
# File 'lib/edoors/iota.rb', line 50

def viewer
  @viewer
end

Instance Method Details

#hibernate!Object

override this to save your object state on hibernate



64
65
66
# File 'lib/edoors/iota.rb', line 64

def hibernate!
    {}
end

#receive_p(p) ⇒ Object

has to be override, used by user side code

Raises:

  • NoMethodError



77
78
79
# File 'lib/edoors/iota.rb', line 77

def receive_p p
    raise NoMethodError.new "#{self.path} receive_p(p) must be overridden"
end

#resume!(o) ⇒ Object

override this to restore your object state on resume



70
71
# File 'lib/edoors/iota.rb', line 70

def resume! o
end

#start!Object

override this to initialize your object on system start



54
55
# File 'lib/edoors/iota.rb', line 54

def start!
end

#stop!Object

override this to initialize your object on system stop



59
60
# File 'lib/edoors/iota.rb', line 59

def stop!
end