Class: MessagePackPure::Packer
- Inherits:
-
Object
- Object
- MessagePackPure::Packer
- Defined in:
- lib/msgpack_pure/packer.rb,
lib/msgpack_pure/packer.rb
Instance Attribute Summary collapse
-
#io ⇒ Object
readonly
Returns the value of attribute io.
Instance Method Summary collapse
-
#initialize(io) ⇒ Packer
constructor
A new instance of Packer.
- #write(value) ⇒ Object
Constructor Details
#initialize(io) ⇒ Packer
Returns a new instance of Packer.
12 13 14 |
# File 'lib/msgpack_pure/packer.rb', line 12 def initialize(io) @io = io end |
Instance Attribute Details
#io ⇒ Object (readonly)
Returns the value of attribute io.
16 17 18 |
# File 'lib/msgpack_pure/packer.rb', line 16 def io @io end |
Instance Method Details
#write(value) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/msgpack_pure/packer.rb', line 18 def write(value) case value when Integer then self.write_integer(value) when NilClass then self.write_nil when TrueClass then self.write_true when FalseClass then self.write_false when Float then self.write_float(value) when String then self.write_string(value) when Array then self.write_array(value) when Hash then self.write_hash(value) else raise("unknown type") end return @io end |