Permalink
Browse files

updated msgpack.org.md

  • Loading branch information...
1 parent 228bf03 commit 43f771fcfa58d423c068be7d6bd9ab4dd5d048ea @frsyuki frsyuki committed Dec 14, 2013
Showing with 10 additions and 11 deletions.
  1. +10 −11 msgpack.org.md
View
@@ -1,14 +1,14 @@
# MessagePack for Ruby
-```ruby
+```
require 'msgpack'
msg = [1,2,3].to_msgpack #=> "\x93\x01\x02\x03"
MessagePack.unpack(msg) #=> [1,2,3]
```
## Install
-```ruby
+```
gem install msgpack
```
@@ -18,30 +18,29 @@ gem install msgpack
* Store objects efficiently in memcached or Redis
* Upload data in efficient format from mobile devices. See also MessagePack for [Objective-C](https://github.com/msgpack/msgpack-objectivec) and [Java](https://github.com/msgpack/msgpack-java)
+## Links
+
+* [Github](https://github.com/msgpack/msgpack-ruby)
+* [API document](http://ruby.msgpack.org/)
+
## Streaming API
-```ruby
+```
# serialize a 2-element array [e1, e2]
pk = MessagePack::Packer.new(io)
pk.write_array_header(2).write(e1).write(e2).flush
```
-```ruby
+```
# deserialize objects from an IO
u = MessagePack::Unpacker.new(io)
u.each { |obj| ... }
```
-```ruby
+```
# event-driven deserialization
def on_read(data)
@u ||= MessagePack::Unpacker.new
@u.feed_each(data) { |obj| ... }
end
```
-
-## Links
-
-* [Github](https://github.com/msgpack/msgpack-ruby)
-* [API document](http://ruby.msgpack.org/)
-

0 comments on commit 43f771f

Please sign in to comment.