Class: Fzeet::Handle

Inherits:
Object
  • Object
show all
Defined in:
lib/fzeet/Common.rb

Constant Summary collapse

@@instances =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#handleObject (readonly)

Returns the value of attribute handle.



179
180
181
# File 'lib/fzeet/Common.rb', line 179

def handle
  @handle
end

Class Method Details

.instance(handle) ⇒ Object



169
# File 'lib/fzeet/Common.rb', line 169

def self.instance(handle) raise "#{self}.#{__method__} failed." unless (instance = @@instances[handle.to_i]); instance end

.instance?(handle) ⇒ Boolean

Returns:

  • (Boolean)


168
# File 'lib/fzeet/Common.rb', line 168

def self.instance?(handle) @@instances.include?(handle.to_i) end

.wrap(handle, iface) ⇒ Object



171
172
173
174
175
176
177
# File 'lib/fzeet/Common.rb', line 171

def self.wrap(handle, iface)
	Object.new.tap { |o|
		o.instance_variable_set(:@handle, handle)
		o.class.send(:attr_reader, :handle)
		o.class.send(:include, iface)
	}
end

Instance Method Details

#attachObject



181
# File 'lib/fzeet/Common.rb', line 181

def attach; @@instances[@handle.to_i] = self end

#detachObject



182
# File 'lib/fzeet/Common.rb', line 182

def detach; @@instances.delete(@handle.to_i) end

#dupObject



184
# File 'lib/fzeet/Common.rb', line 184

def dup; raise "#{self}.#{__method__} is not implemented." end