Class: Torrenter::Tracker
- Inherits:
-
Object
- Object
- Torrenter::Tracker
- Defined in:
- lib/torrenter/tracker.rb,
lib/torrenter/tracker/udp_tracker.rb,
lib/torrenter/tracker/http_tracker.rb
Direct Known Subclasses
Defined Under Namespace
Classes: HTTPTracker, UDPTracker
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
4 5 6 |
# File 'lib/torrenter/tracker/http_tracker.rb', line 4 def address @address end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
4 5 6 |
# File 'lib/torrenter/tracker/http_tracker.rb', line 4 def response @response end |
Instance Method Details
#format_peers(peers) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/torrenter/tracker.rb', line 3 def format_peers(peers) pool = [] peers.chars.each_slice(6) do |peer_data| ip = peer_data[0..3].join('').bytes.join('.') port = peer_data[4..5].join('').unpack("S>").first if !pool.find { |peer| peer.ip == ip } pool << Peer.new(ip, port, @params) end end return pool end |