Class: BitTorrent
- Inherits:
-
Object
- Object
- BitTorrent
- Defined in:
- lib/bit_torrent.rb
Defined Under Namespace
Classes: DownloadError
Constant Summary collapse
- DEFAULTS =
{ :upload_rate_limit => 0, :seed_ratio => 1.5, :seed_time => 1440, # minutes :connect_timeout => 60, :timeout => 60, :stop_timeout => 0, :use_tor_proxy => false, :destination_directory => "." }
Instance Attribute Summary collapse
-
#sources ⇒ Object
readonly
Returns the value of attribute sources.
Class Method Summary collapse
Instance Method Summary collapse
- #download ⇒ Object
- #download! ⇒ Object
-
#initialize(source, options = {}) ⇒ BitTorrent
constructor
A new instance of BitTorrent.
Constructor Details
#initialize(source, options = {}) ⇒ BitTorrent
Returns a new instance of BitTorrent.
20 21 22 23 24 25 |
# File 'lib/bit_torrent.rb', line 20 def initialize(source, = {}) @sources = [ source ].flatten DEFAULTS.keys.each do |option| self.instance_variable_set("@#{option}", ([option] || DEFAULTS[option])) end end |
Instance Attribute Details
#sources ⇒ Object (readonly)
Returns the value of attribute sources.
17 18 19 |
# File 'lib/bit_torrent.rb', line 17 def sources @sources end |
Class Method Details
.download(sources, options = {}) ⇒ Object
27 28 29 |
# File 'lib/bit_torrent.rb', line 27 def self.download(sources, = {}) new(sources, ).download end |
.download!(sources, options = {}) ⇒ Object
31 32 33 |
# File 'lib/bit_torrent.rb', line 31 def self.download!(sources, = {}) new(sources, ).download! end |
Instance Method Details
#download ⇒ Object
35 36 37 |
# File 'lib/bit_torrent.rb', line 35 def download system(download_commmand) end |
#download! ⇒ Object
39 40 41 |
# File 'lib/bit_torrent.rb', line 39 def download! download or raise DownloadError end |