Class: RubyTorrent::TrackerResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/rubytorrent/tracker.rb

Instance Method Summary collapse

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