Class: Menu
- Inherits:
-
Object
- Object
- Menu
- Defined in:
- lib/menu.rb
Overview
:name is optional, otherwise uses the basename of this executable
Instance Attribute Summary collapse
-
#torrentify ⇒ Object
Returns the value of attribute torrentify.
Instance Method Summary collapse
-
#initialize(torrentify = Torrentify) ⇒ Menu
constructor
A new instance of Menu.
- #start ⇒ Object
Constructor Details
#initialize(torrentify = Torrentify) ⇒ Menu
Returns a new instance of Menu.
13 14 15 |
# File 'lib/menu.rb', line 13 def initialize(torrentify = Torrentify) @torrentify = torrentify end |
Instance Attribute Details
#torrentify ⇒ Object
Returns the value of attribute torrentify.
17 18 19 |
# File 'lib/menu.rb', line 17 def torrentify @torrentify end |
Instance Method Details
#start ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/menu.rb', line 19 def start command :search do |c| c.syntax = 'search foo' c.description = 'Search for torrents ' c.option '--search-engine PIRATEBAY', String, 'Search piratebay' c.option '--search-engine ISOHUNT', String, 'Search isohunt' c.option '--search-engine KICKASS', String, 'Search kickass' c.option '--search-engine EXTRATORRENT', String, 'Search extratorrent' c.option '--search-engine ALL', String, 'Default. Searches all sites' c.action do |args, | .default :search_engine => 'ALL' results = @torrentify.search args.join(' '), .search_engine results.each do |result| puts '---------------------------------' puts 'new search-engine' puts '---------------------------------' result.each do |torrent| puts torrent end end end end command :imdb do |c| c.syntax = 'imdb userid' c.description = 'Searches torrents for all movies on imdb watchlist' c.action do |args| imdb_user_id = '' if args.first.nil? yaml = YAML.load_file('.settings.yml') imdb_user_id = yaml['imdb_user_id'].first else imdb_user_id = args.first end results = @torrentify.imdb_watchlist(imdb_user_id) results.each do |result| search_result = @torrentify.search_all_return_best(result) puts search_result end end end command :bar do |c| c.syntax = 'foobar bar [options]' c.description = 'Display bar with optional prefix and suffix' c.option '--prefix STRING', String, 'Adds a prefix to bar' c.option '--suffix STRING', String, 'Adds a suffix to bar' c.action do |_args, | .default :prefix => '(', :suffix => ')' say "#{.prefix}bar#{.suffix}" end end end |