Class: TransmissionApi::ClientFake
- Defined in:
- lib/transmission_api/client_fake.rb
Constant Summary
Constants inherited from Client
TransmissionApi::Client::TORRENT_FIELDS
Instance Attribute Summary collapse
-
#torrents ⇒ Object
readonly
Returns the value of attribute torrents.
Attributes inherited from Client
#basic_auth, #debug_mode, #fields, #session_id, #url
Instance Method Summary collapse
- #all ⇒ Object
- #create(filename) ⇒ Object
- #destroy(id) ⇒ Object
- #find(id) ⇒ Object
-
#initialize(opts) ⇒ ClientFake
constructor
A new instance of ClientFake.
Methods inherited from Client
#http_post, #log, #log_response, #post
Constructor Details
#initialize(opts) ⇒ ClientFake
Returns a new instance of ClientFake.
5 6 7 8 9 |
# File 'lib/transmission_api/client_fake.rb', line 5 def initialize(opts) super torrents_path = opts[:torrents_path] || "#{File.dirname(__FILE__)}/../torrents_fake.json" @torrents = JSON.parse(File.read(torrents_path)) end |
Instance Attribute Details
#torrents ⇒ Object (readonly)
Returns the value of attribute torrents.
3 4 5 |
# File 'lib/transmission_api/client_fake.rb', line 3 def torrents @torrents end |
Instance Method Details
#all ⇒ Object
11 12 13 |
# File 'lib/transmission_api/client_fake.rb', line 11 def all torrents end |
#create(filename) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/transmission_api/client_fake.rb', line 19 def create(filename) torrent = { "files" => [], "hashString" => "77831ec368308f1031434c5581a76fd0c3e06cfd", "name" => "No Media Kings - Ghosts With Shit Jobs trailer", "percentDone" => 0, "rateUpload" => 0, "rateDownload" => 0, "totalSize" => 100 } torrents << torrent torrent end |
#destroy(id) ⇒ Object
35 36 37 |
# File 'lib/transmission_api/client_fake.rb', line 35 def destroy(id) torrents.delete_if { |e| e["hashString"] == id } end |
#find(id) ⇒ Object
15 16 17 |
# File 'lib/transmission_api/client_fake.rb', line 15 def find(id) torrents.select { |e| e["hashString"] == id }.first end |