Class: Transmission::RPC

Inherits:
Object
  • Object
show all
Defined in:
lib/transmission/rpc.rb,
lib/transmission/rpc/connector.rb

Defined Under Namespace

Classes: Connector

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ RPC

Returns a new instance of RPC.



8
9
10
# File 'lib/transmission/rpc.rb', line 8

def initialize(options = {})
  @connector = Connector.new options
end

Instance Attribute Details

#connectorObject

Returns the value of attribute connector.



6
7
8
# File 'lib/transmission/rpc.rb', line 6

def connector
  @connector
end

#sessionObject

Returns the value of attribute session.



6
7
8
# File 'lib/transmission/rpc.rb', line 6

def session
  @session
end

Instance Method Details

#add_torrent(arguments) ⇒ Object



58
59
60
61
# File 'lib/transmission/rpc.rb', line 58

def add_torrent(arguments)
  arguments = Transmission::Arguments::TorrentAdd.new(arguments)
  @connector.post method: 'torrent-add', arguments: arguments.to_arguments
end

#blocklistObject



32
33
34
# File 'lib/transmission/rpc.rb', line 32

def blocklist
  @connector.post method: 'blocklist-update'
end

#close_sessionObject



24
25
26
# File 'lib/transmission/rpc.rb', line 24

def close_session
  @connector.post method: 'session-close'
end

#free_spaceObject



36
37
38
# File 'lib/transmission/rpc.rb', line 36

def free_space
  @connector.post method: 'free-space'
end

#get_session(fields = nil) ⇒ Object



12
13
14
15
16
# File 'lib/transmission/rpc.rb', line 12

def get_session(fields = nil)
  fields = Transmission::Fields::SessionGet.new(fields)
  arguments = {fields: fields.to_fields}
  @connector.post method: 'session-get', arguments: arguments
end

#get_session_stats(fields = nil) ⇒ Object



18
19
20
21
22
# File 'lib/transmission/rpc.rb', line 18

def get_session_stats(fields = nil)
  fields = Transmission::Fields::SessionStats.new(fields)
  arguments = {fields: fields.to_fields}
  @connector.post method: 'session-stats', arguments: arguments
end

#get_torrent(ids, fields = nil) ⇒ Object



40
41
42
43
44
45
# File 'lib/transmission/rpc.rb', line 40

def get_torrent(ids, fields = nil)
  fields = Transmission::Fields::TorrentGet.new(fields)
  arguments = {fields: fields.to_fields}
  arguments[:ids] = ids if ids.is_a? Array
  @connector.post method: 'torrent-get', arguments: arguments
end

#move_bottom_torrent(ids) ⇒ Object



105
106
107
# File 'lib/transmission/rpc.rb', line 105

def move_bottom_torrent(ids)
  @connector.post method: 'queue-move-bottom', arguments: id_arguments(ids)
end

#move_down_torrent(ids) ⇒ Object



97
98
99
# File 'lib/transmission/rpc.rb', line 97

def move_down_torrent(ids)
  @connector.post method: 'queue-move-down', arguments: id_arguments(ids)
end

#move_top_torrent(ids) ⇒ Object



101
102
103
# File 'lib/transmission/rpc.rb', line 101

def move_top_torrent(ids)
  @connector.post method: 'queue-move-top', arguments: id_arguments(ids)
end

#move_up_torrent(ids) ⇒ Object



93
94
95
# File 'lib/transmission/rpc.rb', line 93

def move_up_torrent(ids)
  @connector.post method: 'queue-move-up', arguments: id_arguments(ids)
end

#re_announce_torrent(ids) ⇒ Object



89
90
91
# File 'lib/transmission/rpc.rb', line 89

def re_announce_torrent(ids)
  @connector.post method: 'torrent-reannounce', arguments: id_arguments(ids)
end

#remove_torrent(ids, delete_local_data = false) ⇒ Object



69
70
71
# File 'lib/transmission/rpc.rb', line 69

def remove_torrent(ids, delete_local_data = false)
  @connector.post method: 'torrent-remove', arguments: {ids: ids, 'delete-local-data' => delete_local_data}
end

#set_session(arguments) ⇒ Object



53
54
55
56
# File 'lib/transmission/rpc.rb', line 53

def set_session(arguments)
  arguments = Transmission::Arguments::SessionSet.new(arguments)
  @connector.post method: 'session-set', arguments: arguments.to_arguments
end

#set_torrent(ids, arguments) ⇒ Object



47
48
49
50
51
# File 'lib/transmission/rpc.rb', line 47

def set_torrent(ids, arguments)
  arguments[:ids] = ids
  arguments = Transmission::Arguments::TorrentSet.new(arguments)
  @connector.post method: 'torrent-set', arguments: arguments.to_arguments
end

#start_torrent(ids) ⇒ Object



73
74
75
# File 'lib/transmission/rpc.rb', line 73

def start_torrent(ids)
  @connector.post method: 'torrent-start', arguments: id_arguments(ids)
end

#start_torrent_now(ids) ⇒ Object



77
78
79
# File 'lib/transmission/rpc.rb', line 77

def start_torrent_now(ids)
  @connector.post method: 'torrent-start-now', arguments: id_arguments(ids)
end

#stop_torrent(ids) ⇒ Object



81
82
83
# File 'lib/transmission/rpc.rb', line 81

def stop_torrent(ids)
  @connector.post method: 'torrent-stop', arguments: id_arguments(ids)
end

#test_portObject



28
29
30
# File 'lib/transmission/rpc.rb', line 28

def test_port
  @connector.post method: 'port-test'
end

#torrent_set_location(ids, arguments) ⇒ Object



63
64
65
66
67
# File 'lib/transmission/rpc.rb', line 63

def torrent_set_location(ids, arguments)
  arguments[:ids] = ids
  arguments = Transmission::Arguments::LocationSet.new(arguments)
  @connector.post method: 'torrent-set-location', arguments: arguments.to_arguments
end

#verify_torrent(ids) ⇒ Object



85
86
87
# File 'lib/transmission/rpc.rb', line 85

def verify_torrent(ids)
  @connector.post method: 'torrent-verify', arguments: id_arguments(ids)
end