Class: RubyTorrent::TrackerResponse
- Inherits:
-
Object
- Object
- RubyTorrent::TrackerResponse
- Defined in:
- lib/rubytorrent/tracker.rb
Instance Method Summary collapse
-
#initialize(dict = nil) ⇒ TrackerResponse
constructor
A new instance of TrackerResponse.
- #method_missing(meth, *args) ⇒ Object
Constructor Details
#initialize(dict = nil) ⇒ TrackerResponse
Returns a new instance of TrackerResponse.
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/rubytorrent/tracker.rb', line 67 def initialize(dict=nil) @s = TypedStruct.new do |s| s.field :interval => Integer, :complete => Integer, :incomplete => Integer, :peers => TrackerResponsePeer s.array :peers s.required :peers #:interval, :complete, :incomplete, :peers s.coerce :peers => lambda { |x| make_peers x } end @s.parse(dict) unless dict.nil? peers.extend ArrayShuffle end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args) ⇒ Object
81 82 83 |
# File 'lib/rubytorrent/tracker.rb', line 81 def method_missing(meth, *args) @s.send(meth, *args) end |