Commit 1ad1ffc2ae476b4ccf2895d9b112987dd7e25c6e

Anton Maminov 2022-05-05T22:05:24

Update README.md

diff --git a/README.md b/README.md
index 0033700..2ff751e 100644
--- a/README.md
+++ b/README.md
@@ -31,6 +31,8 @@ gem install mpd_client
 All functionality is contained in the `MPD::Client` class. Creating an instance of this class is as simple as:
 
 ```ruby
+require 'mpd_client'
+
 client = MPD::Client.new
 ```
 
@@ -64,6 +66,26 @@ client.status                # insert the status command into the list
 client.command_list_end      # result will be a Array with the results
 ```
 
+### Binary responses
+
+Some commands can return binary data.
+
+```ruby
+require 'mpd_client'
+
+client = MPD::Client.new
+client.connect('localhost', 6600)
+
+if (current_song = client.currentsong)
+  data, io = client.albumart(current_song['file'])
+  io # StringIO
+  data # => {"size"=>"322860", "binary"=>"3372"}
+  File.write('cover.jpg', io.string)
+end
+```
+
+The above will locate album art for the current song and save image to `cover.jpg` file.
+
 ### Ranges
 
 Some commands(e.g. `move`, `delete`, `load`, `shuffle`, `playlistinfo`) support integer ranges(`[START:END]`) as argument. This is done in `mpd_client` by using two element array: