Class: Retort::Torrent
Constant Summary
Constants inherited from Rtorrent
Class Method Summary collapse
Instance Method Summary collapse
- #actions ⇒ Object
- #commit_priorities ⇒ Object
- #completed_ratio ⇒ Object
- #files ⇒ Object
-
#initialize(attributes) ⇒ Torrent
constructor
A new instance of Torrent.
- #status ⇒ Object
Methods inherited from Rtorrent
Constructor Details
#initialize(attributes) ⇒ Torrent
Returns a new instance of Torrent.
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/retort/torrent.rb', line 54 def initialize(attributes) attributes.each do |attrib, value| variable = "@#{attrib}".to_sym self.instance_variable_set variable, value if attrib =~ /is_/ bool_value = value.truth variable = "@#{attrib.to_s.gsub(/is_/, "")}".to_sym self.instance_variable_set variable, bool_value end end end |
Class Method Details
.action(name, info_hash) ⇒ Object
47 48 49 |
# File 'lib/retort/torrent.rb', line 47 def action(name, info_hash) Service.call "d.#{name}", info_hash end |
.all(view = "main") ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/retort/torrent.rb', line 31 def all(view="main") methods = attributes.map {|key,value| "#{value}="} Service.call("d.multicall", view, *methods).map do |r| attributes = Hash[self.attributes.keys.zip(r)] Torrent.new attributes end end |
Instance Method Details
#actions ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/retort/torrent.rb', line 76 def actions actions = [] actions << (@state.truth ? :stop : :start) #actions << :check_hash unless @hash_checking actions << (@open ? :close : :open) unless @complete.truth actions << (@active ? :pause : :resume) end actions << :erase actions end |
#commit_priorities ⇒ Object
94 95 96 |
# File 'lib/retort/torrent.rb', line 94 def commit_priorities Service.call("d.update_priorities",self.info_hash) end |
#completed_ratio ⇒ Object
68 69 70 |
# File 'lib/retort/torrent.rb', line 68 def completed_ratio self.completed_raw/(self.size_raw.to_f) end |
#files ⇒ Object
91 92 93 |
# File 'lib/retort/torrent.rb', line 91 def files File.all(self.info_hash) end |
#status ⇒ Object
72 73 74 |
# File 'lib/retort/torrent.rb', line 72 def status return "complete" if @complete.truth end |