Class: Torckapi::Response::Announce
- Defined in:
- lib/torckapi/response/announce.rb
Overview
Announce response
Instance Attribute Summary collapse
-
#info_hash ⇒ String
readonly
40-char hexadecimal string.
-
#leechers ⇒ Fixnum
readonly
Number of leechers.
-
#peers ⇒ Array<IPAddr, Fixnum>
readonly
List of peers.
-
#seeders ⇒ Object
readonly
Returns the value of attribute seeders.
Class Method Summary collapse
-
.from_http(info_hash, data) ⇒ Torckapi::Response::Announce
Construct response object from http response data.
-
.from_udp(info_hash, data) ⇒ Torckapi::Response::Announce
Construct response object from udp response data.
Instance Attribute Details
#info_hash ⇒ String (readonly)
Returns 40-char hexadecimal string.
17 18 19 |
# File 'lib/torckapi/response/announce.rb', line 17 def info_hash @info_hash end |
#leechers ⇒ Fixnum (readonly)
Returns number of leechers.
17 |
# File 'lib/torckapi/response/announce.rb', line 17 attr_reader :info_hash, :leechers, :peers, :seeders |
#peers ⇒ Array<IPAddr, Fixnum> (readonly)
Returns list of peers.
17 |
# File 'lib/torckapi/response/announce.rb', line 17 attr_reader :info_hash, :leechers, :peers, :seeders |
#seeders ⇒ Object (readonly)
Returns the value of attribute seeders.
17 |
# File 'lib/torckapi/response/announce.rb', line 17 attr_reader :info_hash, :leechers, :peers, :seeders |
Class Method Details
.from_http(info_hash, data) ⇒ Torckapi::Response::Announce
Construct response object from http response data
32 33 34 35 |
# File 'lib/torckapi/response/announce.rb', line 32 def self.from_http info_hash, data bdecoded_data = bdecode_and_check data, 'peers' new info_hash, *bdecoded_data.values_at('incomplete', 'complete'), peers_from_compact(bdecoded_data['peers']) end |
.from_udp(info_hash, data) ⇒ Torckapi::Response::Announce
Construct response object from udp response data
23 24 25 |
# File 'lib/torckapi/response/announce.rb', line 23 def self.from_udp info_hash, data new info_hash, *data[4..11].unpack('L>2'), peers_from_compact(data[12..-1] || '') end |