Class: TorrentFinder::Command
- Inherits:
-
CLAide::Command
- Object
- CLAide::Command
- TorrentFinder::Command
- Defined in:
- lib/torrent-finder/command.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Command
constructor
A new instance of Command.
- #run ⇒ Object
Constructor Details
#initialize(argv) ⇒ Command
Returns a new instance of Command.
16 17 18 19 20 21 22 |
# File 'lib/torrent-finder/command.rb', line 16 def initialize(argv) @use_peerflix = argv.flag?('peerflix', false) @site = argv.option('site', "popgo") @keywords = argv.shift_argument super end |
Class Method Details
.options ⇒ Object
9 10 11 12 13 14 |
# File 'lib/torrent-finder/command.rb', line 9 def self. [ ['--peerflix', 'launch peerflix with first matched result'], ['--site=site', 'use site, default popgo'] ].concat(super) end |
Instance Method Details
#run ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/torrent-finder/command.rb', line 24 def run require "torrent-finder/adapters/#{@site}_adapter" adapter_clazz = TorrentFinder::Adapters::Registry.adapters.first adapter = adapter_clazz.new if @keywords torrents = adapter.search(@keywords) else torrents = adapter.list end if @use_peerflix torrent = torrents.find {|torrent| torrent.name.include?(@keywords) } || torrents.first exec %{peerflix #{torrent.url} --vlc} else torrents.each do |torrent| puts "#{torrent.name},#{torrent.url}" end end end |