Class: Wikian::Search
- Inherits:
-
Subcommand
- Object
- Subcommand
- Wikian::Search
- Defined in:
- lib/wikian/search.rb
Instance Attribute Summary
Attributes inherited from Subcommand
#api_url, #args, #debug, #output_file, #query, #res, #title, #yaml
Instance Method Summary collapse
-
#initialize(args) ⇒ Search
constructor
A new instance of Search.
- #template ⇒ Object
Methods inherited from Subcommand
#doit, #make_template, #response_file, #write_response
Constructor Details
#initialize(args) ⇒ Search
Returns a new instance of Search.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/wikian/search.rb', line 6 def initialize(args) super @output_file = yaml['api']['srsearch'].first @params.merge!('format' => Wikian::RESPONSE_FORMAT) @query = @params.to_query @api_url = URI("https://#{yaml['meta']['site']}/w/api.php?#{query}") rescue => e puts "#{e.class} in #{__FILE__}. #{e.message}" exit end |
Instance Method Details
#template ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/wikian/search.rb', line 21 def template " # Get last 5 revisions of the Main Page.\n meta:\n site: en.wikipedia.org\n headers:\n user-agent: Wikian\n api:\n action:\n - query\n list:\n - search\n srsearch: # text to search for. You can use multiple\n - Mr. Fixit\n eos\nend\n" |