Class: Hci::Hit
- Inherits:
-
Object
- Object
- Hci::Hit
- Defined in:
- lib/hci/hit.rb
Class Attribute Summary collapse
-
.hits ⇒ Object
Returns the value of attribute hits.
Instance Attribute Summary collapse
-
#answer_options ⇒ Object
Returns the value of attribute answer_options.
-
#answer_type ⇒ Object
Returns the value of attribute answer_type.
-
#directions ⇒ Object
Returns the value of attribute directions.
-
#image_url ⇒ Object
Returns the value of attribute image_url.
-
#name ⇒ Object
Returns the value of attribute name.
-
#replace ⇒ Object
whether hits with the same resource id and name should be overwritten.
-
#responses_required ⇒ Object
Returns the value of attribute responses_required.
Class Method Summary collapse
- .cancel(name, options) ⇒ Object
- .clear! ⇒ Object
- .define(name) {|hit| ... } ⇒ Object
- .find(name) ⇒ Object
- .request(name, options) ⇒ Object
Instance Method Summary collapse
- #cancel(options) ⇒ Object
- #complete!(results) ⇒ Object
- #fail!(results) ⇒ Object
-
#on_completion(&block) ⇒ Object
Callbacks.
- #on_failure(&block) ⇒ Object
- #request(options) ⇒ Object
- #to_hash ⇒ Object
Class Attribute Details
.hits ⇒ Object
Returns the value of attribute hits.
6 7 8 |
# File 'lib/hci/hit.rb', line 6 def hits @hits end |
Instance Attribute Details
#answer_options ⇒ Object
Returns the value of attribute answer_options.
43 44 45 |
# File 'lib/hci/hit.rb', line 43 def @answer_options end |
#answer_type ⇒ Object
Returns the value of attribute answer_type.
44 45 46 |
# File 'lib/hci/hit.rb', line 44 def answer_type @answer_type end |
#directions ⇒ Object
Returns the value of attribute directions.
41 42 43 |
# File 'lib/hci/hit.rb', line 41 def directions @directions end |
#image_url ⇒ Object
Returns the value of attribute image_url.
42 43 44 |
# File 'lib/hci/hit.rb', line 42 def image_url @image_url end |
#name ⇒ Object
Returns the value of attribute name.
40 41 42 |
# File 'lib/hci/hit.rb', line 40 def name @name end |
#replace ⇒ Object
whether hits with the same resource id and name should be overwritten
46 47 48 |
# File 'lib/hci/hit.rb', line 46 def replace @replace end |
#responses_required ⇒ Object
Returns the value of attribute responses_required.
45 46 47 |
# File 'lib/hci/hit.rb', line 45 def responses_required @responses_required end |
Class Method Details
.cancel(name, options) ⇒ Object
26 27 28 |
# File 'lib/hci/hit.rb', line 26 def cancel(name, ) @hits[name].cancel() end |
.clear! ⇒ Object
34 35 36 |
# File 'lib/hci/hit.rb', line 34 def clear! @hits = {} end |
.define(name) {|hit| ... } ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/hci/hit.rb', line 12 def define(name, &block) raise ConfigurationError, "Please set your Hci api key with Hci::Client.api_key = 'your-api-key-here'" unless Client.api_key raise ConfigurationError, "Please set your callback URL with Hci::Client.callback_host = 'www.your-domain-name.com'" unless Client.callback_host hit = self.new hit.name = name yield hit self.hits[name] = hit end |
.find(name) ⇒ Object
30 31 32 |
# File 'lib/hci/hit.rb', line 30 def find(name) self.hits[name] end |
.request(name, options) ⇒ Object
22 23 24 |
# File 'lib/hci/hit.rb', line 22 def request(name, ) @hits[name].request() end |
Instance Method Details
#cancel(options) ⇒ Object
57 58 59 60 |
# File 'lib/hci/hit.rb', line 57 def cancel() hit_request = HitRequest.new(self, ) hit_request.cancel end |
#complete!(results) ⇒ Object
81 82 83 |
# File 'lib/hci/hit.rb', line 81 def complete!(results) @on_complete_proc.call(results) if @on_complete_proc end |
#fail!(results) ⇒ Object
89 90 91 |
# File 'lib/hci/hit.rb', line 89 def fail!(results) @on_failure_proc.call(results) if @on_failure_proc end |
#on_completion(&block) ⇒ Object
Callbacks
77 78 79 |
# File 'lib/hci/hit.rb', line 77 def on_completion(&block) @on_complete_proc = block end |
#on_failure(&block) ⇒ Object
85 86 87 |
# File 'lib/hci/hit.rb', line 85 def on_failure(&block) @on_failure_proc = block end |
#request(options) ⇒ Object
52 53 54 55 |
# File 'lib/hci/hit.rb', line 52 def request() hit_request = HitRequest.new(self, ) hit_request.create end |
#to_hash ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/hci/hit.rb', line 62 def to_hash { :name=>name, :directions => directions, :image_url => image_url, :answer_options => , :responses_required => responses_required, :answer_type => answer_type.to_s, :callback_url => Client.callback_url, :replace => replace } end |