Class: RUTorrent::Server
- Inherits:
-
Object
- Object
- RUTorrent::Server
- Defined in:
- lib/rutorrent/server.rb
Constant Summary
- TOKEN_PATH =
'/gui/token.html'
Instance Attribute Summary (collapse)
-
- (Object) build
readonly
Returns the value of attribute build.
-
- (Object) host
readonly
Returns the value of attribute host.
-
- (Object) port
readonly
Returns the value of attribute port.
-
- (Object) token
readonly
Returns the value of attribute token.
-
- (Object) user
readonly
Returns the value of attribute user.
Instance Method Summary (collapse)
-
- (Server) initialize(host, port, user, pass)
constructor
A new instance of Server.
- - (Object) inspect
- - (Object) labels
- - (Object) reload
- - (Object) request(args)
- - (Object) rssfilters
- - (Object) settings
- - (Object) torrents
Constructor Details
- (Server) initialize(host, port, user, pass)
A new instance of Server
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rutorrent/server.rb', line 12 def initialize(host, port, user, pass) @host = host @port = port @user = user @pass = pass @token = nil @build = nil @http = Net::HTTP.new(@host, @port) get_token end |
Instance Attribute Details
- (Object) build (readonly)
Returns the value of attribute build
10 11 12 |
# File 'lib/rutorrent/server.rb', line 10 def build @build end |
- (Object) host (readonly)
Returns the value of attribute host
10 11 12 |
# File 'lib/rutorrent/server.rb', line 10 def host @host end |
- (Object) port (readonly)
Returns the value of attribute port
10 11 12 |
# File 'lib/rutorrent/server.rb', line 10 def port @port end |
- (Object) token (readonly)
Returns the value of attribute token
10 11 12 |
# File 'lib/rutorrent/server.rb', line 10 def token @token end |
- (Object) user (readonly)
Returns the value of attribute user
10 11 12 |
# File 'lib/rutorrent/server.rb', line 10 def user @user end |
Instance Method Details
- (Object) inspect
81 82 83 |
# File 'lib/rutorrent/server.rb', line 81 def inspect '#<%s:0x%8x %s@%s:%s>' % [self.class, object_id * 2, @user, @host, @port] end |
- (Object) labels
30 31 32 33 |
# File 'lib/rutorrent/server.rb', line 30 def labels reload unless @labels @labels end |
- (Object) reload
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/rutorrent/server.rb', line 62 def reload json = request(:list => 1) @labels = [] json['label'].each do |label| @labels << Label.new(label) end @torrents = [] json['torrents'].each do |torrent| @torrents << Torrent.new(self, torrent) end @rssfilters = [] json['rssfilters'].each do |rssfilter| @rssfilters << RSSFilter.new(rssfilter) end end |
- (Object) request(args)
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/rutorrent/server.rb', line 45 def request(args) args[:token] ||= @token if @token path = RUTorrent::Helpers::URLHelper.path_for(args) resp = request_raw(path) begin json = JSON.parse(resp.body) @build = json['build'] if json.has_key?('build') ret = json rescue ret = resp.body end ret end |
- (Object) rssfilters
40 41 42 43 |
# File 'lib/rutorrent/server.rb', line 40 def rssfilters reload unless @rssfilters @rssfilters end |
- (Object) settings
26 27 28 |
# File 'lib/rutorrent/server.rb', line 26 def settings @settings ||= RUTorrent::Settings.new(self) end |
- (Object) torrents
35 36 37 38 |
# File 'lib/rutorrent/server.rb', line 35 def torrents reload unless @torrents @torrents end |