Class: Torrenter::Tracker::HTTPTracker
- Inherits:
-
Torrenter::Tracker
- Object
- Torrenter::Tracker
- Torrenter::Tracker::HTTPTracker
- Defined in:
- lib/torrenter/tracker/http_tracker.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Attributes inherited from Torrenter::Tracker
Instance Method Summary collapse
- #connect ⇒ Object
- #connect_interval ⇒ Object
- #connected? ⇒ Boolean
-
#initialize(url, params) ⇒ HTTPTracker
constructor
A new instance of HTTPTracker.
- #peer_list ⇒ Object
- #peers ⇒ Object
Methods inherited from Torrenter::Tracker
Constructor Details
#initialize(url, params) ⇒ HTTPTracker
Returns a new instance of HTTPTracker.
8 9 10 11 |
# File 'lib/torrenter/tracker/http_tracker.rb', line 8 def initialize(url, params) @address = URI(url) @params = params end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
7 8 9 |
# File 'lib/torrenter/tracker/http_tracker.rb', line 7 def response @response end |
Instance Method Details
#connect ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/torrenter/tracker/http_tracker.rb', line 13 def connect @address.query = URI.encode_www_form(@params) begin @response = BEncode.load(Net::HTTP.get(@address)) rescue Exception => e false end return self end |
#connect_interval ⇒ Object
28 29 30 |
# File 'lib/torrenter/tracker/http_tracker.rb', line 28 def connect_interval @response['min interval'] end |
#connected? ⇒ Boolean
36 37 38 |
# File 'lib/torrenter/tracker/http_tracker.rb', line 36 def connected? @response end |
#peer_list ⇒ Object
24 25 26 |
# File 'lib/torrenter/tracker/http_tracker.rb', line 24 def peer_list format_peers(peers) end |
#peers ⇒ Object
32 33 34 |
# File 'lib/torrenter/tracker/http_tracker.rb', line 32 def peers @response['peers'] end |