Class: GoogleSearchCriterion::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/google_search_criterion/cli.rb

Instance Method Summary collapse

Instance Method Details

#get(*keyphrases) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/google_search_criterion/cli.rb', line 20

def get(*keyphrases)
  puts "Nothing to show" if keyphrases.empty?

  keyphrases.each do |keyphrase|
    puts "#{keyphrase} => #{GoogleSearchCriterion::Search.results(keyphrase)}"
  end
end

#sort(*keyphrases) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/google_search_criterion/cli.rb', line 8

def sort(*keyphrases)
  keyphrases.map! do |keyphrase|
    { keyphrase: keyphrase,
      results: GoogleSearchCriterion::Search.results(keyphrase) }
  end.sort! { |x, y| y[:results] <=> x[:results]  }

  keyphrases.each do |keyphrase|
    puts "#{keyphrase[:keyphrase]} => #{keyphrase[:results]}"
  end
end