Module: MdnQuery
- Defined in:
- lib/mdn_query.rb,
lib/mdn_query/list.rb,
lib/mdn_query/entry.rb,
lib/mdn_query/table.rb,
lib/mdn_query/errors.rb,
lib/mdn_query/search.rb,
lib/mdn_query/section.rb,
lib/mdn_query/version.rb,
lib/mdn_query/document.rb,
lib/mdn_query/traverse_dom.rb,
lib/mdn_query/search_result.rb
Overview
Query the Mozilla Developer Network documentation.
Defined Under Namespace
Classes: Document, Entry, Error, HttpRequestFailed, List, NoEntryFound, Search, SearchResult, Section, Table, TraverseDom
Constant Summary collapse
- BASE_URL =
The base url for the search queries.
'https://developer.mozilla.org/search'.freeze
- VERSION =
The version of the gem
'0.2.3'.freeze
Class Method Summary collapse
-
.first_match(query, options = {}) ⇒ MdnQuery::Document
Searches the given query and returns the first fetched entry in the list.
-
.list(query, options = {}) ⇒ MdnQuery::List
Searches the given query and creates a list with the results.
-
.open_first_match(query, options = {}) ⇒ void
Searches the given query and opens the first entry in the default browser.
-
.open_list(query, options = {}) ⇒ void
Searches the given query and opens the result in the default browser.
Class Method Details
.first_match(query, options = {}) ⇒ MdnQuery::Document
Searches the given query and returns the first fetched entry in the list.
48 49 50 51 |
# File 'lib/mdn_query.rb', line 48 def self.first_match(query, = {}) entry = list(query, ).first entry.content end |
.list(query, options = {}) ⇒ MdnQuery::List
Searches the given query and creates a list with the results.
31 32 33 34 35 36 37 38 |
# File 'lib/mdn_query.rb', line 31 def self.list(query, = {}) search = MdnQuery::Search.new(query, ) list = search.execute.to_list if list.empty? raise MdnQuery::NoEntryFound.new(query, ), 'No entry found' end list end |
.open_first_match(query, options = {}) ⇒ void
This method returns an undefined value.
Searches the given query and opens the first entry in the default browser.
74 75 76 77 |
# File 'lib/mdn_query.rb', line 74 def self.open_first_match(query, = {}) entry = list(query, ).first entry.open end |