Class: Moc::Protocol::Integer

Inherits:
BasicObject
Extended by:
Type
Defined in:
lib/moc/protocol/integer.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Type

read, unpack

Constructor Details

#initialize(value) ⇒ Integer

Returns a new instance of Integer.



20
21
22
# File 'lib/moc/protocol/integer.rb', line 20

def initialize (value)
	@internal = value
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(id, *args, &block) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/moc/protocol/integer.rb', line 28

def method_missing (id, *args, &block)
	if @internal.respond_to? id
		return @internal.__send__ id, *args, &block
	end

	super
end

Class Method Details

.read(io) ⇒ Object



16
17
18
# File 'lib/moc/protocol/integer.rb', line 16

def self.read (io)
	new(io.read(4).unpack('i').first)
end

Instance Method Details

#packObject



36
37
38
# File 'lib/moc/protocol/integer.rb', line 36

def pack
	[self].pack('i')
end

#respond_to?(id, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/moc/protocol/integer.rb', line 24

def respond_to? (id, include_private = false)
	return true if id == :pack || @internal.respond_to?(id, include_private)
end