class TransmissionApi::ClientFake
Attributes
torrents[R]
Public Class Methods
new(opts)
click to toggle source
Calls superclass method
TransmissionApi::Client::new
# 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
Public Instance Methods
all()
click to toggle source
# File lib/transmission_api/client_fake.rb, line 11 def all torrents end
create(filename)
click to toggle source
# 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)
click to toggle source
# File lib/transmission_api/client_fake.rb, line 35 def destroy(id) torrents.delete_if { |e| e["hashString"] == id } end
find(id)
click to toggle source
# File lib/transmission_api/client_fake.rb, line 15 def find(id) torrents.select { |e| e["hashString"] == id }.first end