class TorrentSearch::Controllers::Search
Constants
- ACTIONS
Public Class Methods
new(view = Views::Search.new)
click to toggle source
# File lib/torrent_search/controllers/search.rb, line 10 def initialize(view = Views::Search.new) @view = view end
Public Instance Methods
search(search_terms = nil, options = {})
click to toggle source
# File lib/torrent_search/controllers/search.rb, line 14 def search(search_terms = nil, options = {}) search_terms ||= @view.search_terms? perform_search search_terms, options display_menu choose_action! rescue SocketError error 'No network connection?' end
Private Instance Methods
available_actions()
click to toggle source
# File lib/torrent_search/controllers/search.rb, line 51 def available_actions ACTIONS.dup.tap {|hash| hash.delete(:d) unless @search_result.any? } end
choose_action!()
click to toggle source
# File lib/torrent_search/controllers/search.rb, line 41 def choose_action! chosen = @view.action? send available_actions.fetch(chosen, :invalid_command) end
download()
click to toggle source
# File lib/torrent_search/controllers/search.rb, line 33 def download Download.new(@search_result).download end
invalid_command()
click to toggle source
# File lib/torrent_search/controllers/search.rb, line 46 def invalid_command @view.invalid_command! choose_action! end
perform_search(search_terms, options)
click to toggle source
# File lib/torrent_search/controllers/search.rb, line 25 def perform_search(search_terms, options) @search_result = Trackers::KickAss::Scraper.new(search_terms, options).search end
quit()
click to toggle source
# File lib/torrent_search/controllers/search.rb, line 37 def quit CLI::quit end