Module: Idol::BasicIdolFunctionality
- Included in:
- Query, Suggest, SuggestOnText
- Defined in:
- lib/idol-search.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#filters ⇒ Object
Returns the value of attribute filters.
-
#parameters ⇒ Object
Returns the value of attribute parameters.
-
#raw_results ⇒ Object
Returns the value of attribute raw_results.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
23 24 25 |
# File 'lib/idol-search.rb', line 23 def action @action end |
#filters ⇒ Object
Returns the value of attribute filters.
22 23 24 |
# File 'lib/idol-search.rb', line 22 def filters @filters end |
#parameters ⇒ Object
Returns the value of attribute parameters.
22 23 24 |
# File 'lib/idol-search.rb', line 22 def parameters @parameters end |
#raw_results ⇒ Object
Returns the value of attribute raw_results.
22 23 24 |
# File 'lib/idol-search.rb', line 22 def raw_results @raw_results end |
#url ⇒ Object
Returns the value of attribute url.
22 23 24 |
# File 'lib/idol-search.rb', line 22 def url @url end |
Instance Method Details
#execute ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/idol-search.rb', line 40 def execute post_fields = generate_post_fields status = nil body = nil request = Curl::Easy.new do |r| r.url = "#{@url}/?action=#{@action}" r.on_complete do |data| status = data.response_code body = data.body_str end end request.http_post(*post_fields) return body if @raw_results results = if @parameters[:abridged] AbridgedResultsParser.new(body).parse else Hash.from_xml(body) end results end |
#initialize(url, parameters = {}) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/idol-search.rb', line 25 def initialize(url, parameters = {}) @raw_results = false @url = url @parameters = parameters @filters = FieldTextFilterCollection.new end |
#to_hash ⇒ Object
32 33 34 |
# File 'lib/idol-search.rb', line 32 def to_hash @parameters end |