Class: C3D::ConnectTorrent
- Inherits:
-
Object
- Object
- C3D::ConnectTorrent
- Includes:
- Celluloid
- Defined in:
- lib/c3d/connectors/connect_torrent.rb
Constant Summary collapse
- TORRENT_FIELDS =
[ "id", "name", "totalSize", "isFinished", "percentDone", ]
Instance Attribute Summary collapse
-
#basic_auth ⇒ Object
Returns the value of attribute basic_auth.
-
#debug_mode ⇒ Object
Returns the value of attribute debug_mode.
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#session_id ⇒ Object
Returns the value of attribute session_id.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #all ⇒ Object
- #create(filename) ⇒ Object
- #destroy(id) ⇒ Object
- #find(id) ⇒ Object
-
#initialize(opts) ⇒ ConnectTorrent
constructor
A new instance of ConnectTorrent.
Constructor Details
#initialize(opts) ⇒ ConnectTorrent
Returns a new instance of ConnectTorrent.
17 18 19 20 21 22 23 |
# File 'lib/c3d/connectors/connect_torrent.rb', line 17 def initialize opts @url = opts[:url] @fields = opts[:fields] || TORRENT_FIELDS @basic_auth = { :username => opts[:username], :password => opts[:password] } if opts[:username] @debug_mode = opts[:debug_mode] || false @session_id = "c3d-torrent" end |
Instance Attribute Details
#basic_auth ⇒ Object
Returns the value of attribute basic_auth.
7 8 9 |
# File 'lib/c3d/connectors/connect_torrent.rb', line 7 def basic_auth @basic_auth end |
#debug_mode ⇒ Object
Returns the value of attribute debug_mode.
7 8 9 |
# File 'lib/c3d/connectors/connect_torrent.rb', line 7 def debug_mode @debug_mode end |
#fields ⇒ Object
Returns the value of attribute fields.
7 8 9 |
# File 'lib/c3d/connectors/connect_torrent.rb', line 7 def fields @fields end |
#session_id ⇒ Object
Returns the value of attribute session_id.
7 8 9 |
# File 'lib/c3d/connectors/connect_torrent.rb', line 7 def session_id @session_id end |
#url ⇒ Object
Returns the value of attribute url.
7 8 9 |
# File 'lib/c3d/connectors/connect_torrent.rb', line 7 def url @url end |
Instance Method Details
#all ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/c3d/connectors/connect_torrent.rb', line 25 def all log ("[C3D::#{Time.now.strftime( "%F %T" )}] Getting All Torrents"), true response = post( :method => "torrent-get", :arguments => { :fields => fields } ) response["arguments"]["torrents"] end |
#create(filename) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/c3d/connectors/connect_torrent.rb', line 54 def create filename log ("[C3D::#{Time.now.strftime( "%F %T" )}] Adding Blob >>\t\t"+ "#{filename}"), true response = post( :method => "torrent-add", :arguments => { :filename => filename, :'download-dir' => ENV['BLOBS_DIR'], :'peer-limit' => 99 } ) response["arguments"] end |
#destroy(id) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/c3d/connectors/connect_torrent.rb', line 70 def destroy id log ("[C3D::#{Time.now.strftime( "%F %T" )}] Remove Torrent ID >> "+ "#{id}"), true response = post( :method => "torrent-remove", :arguments => { :ids => [id], :"delete-local-data" => true } ) response end |
#find(id) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/c3d/connectors/connect_torrent.rb', line 39 def find id log ("[C3D::#{Time.now.strftime( "%F %T" )}] Getting Torrent ID >> "+ "#{id}"), true response = post( :method => "torrent-get", :arguments => { :fields => fields, :ids => [id] } ) response["arguments"]["torrents"].first end |