Module: Wordhop
- Defined in:
- lib/wordhop.rb
Defined Under Namespace
Classes: Partay
Constant Summary collapse
- EVENTS =
[:'chat response', :'socket_id_set'].freeze
Class Attribute Summary collapse
-
.apikey ⇒ Object
Return a Hash of hooks.
-
.clientkey ⇒ Object
Returns the value of attribute clientkey.
-
.platform ⇒ Object
Returns the value of attribute platform.
-
.token ⇒ Object
Returns the value of attribute token.
Class Method Summary collapse
- .assistanceRequested(x) ⇒ Object
- .headers ⇒ Object
- .hooks ⇒ Object
- .hopIn(x) ⇒ Object
- .hopOut(x) ⇒ Object
- .initialize ⇒ Object
- .logUnknownIntent(x) ⇒ Object
- .new(*args, &block) ⇒ Object
- .on(event, &block) ⇒ Object
- .trigger(event, *args) ⇒ Object
Class Attribute Details
.apikey ⇒ Object
Return a Hash of hooks.
33 34 35 |
# File 'lib/wordhop.rb', line 33 def apikey @apikey end |
.clientkey ⇒ Object
Returns the value of attribute clientkey.
17 18 19 |
# File 'lib/wordhop.rb', line 17 def clientkey @clientkey end |
.platform ⇒ Object
Returns the value of attribute platform.
17 18 19 |
# File 'lib/wordhop.rb', line 17 def platform @platform end |
.token ⇒ Object
Returns the value of attribute token.
17 18 19 |
# File 'lib/wordhop.rb', line 17 def token @token end |
Class Method Details
.assistanceRequested(x) ⇒ Object
110 111 112 113 114 |
# File 'lib/wordhop.rb', line 110 def assistanceRequested(x) puts 'assistanceRequested' = {'body':x, 'headers':headers} return Partay.post('/human', ) end |
.headers ⇒ Object
49 50 51 |
# File 'lib/wordhop.rb', line 49 def headers @headers = {'apikey':apikey,'clientkey':clientkey,'platform':platform, 'token': token} end |
.hooks ⇒ Object
53 54 55 |
# File 'lib/wordhop.rb', line 53 def hooks @hooks ||= {} end |
.hopIn(x) ⇒ Object
92 93 94 95 96 |
# File 'lib/wordhop.rb', line 92 def hopIn(x) puts 'hopIn' = {'body':x, 'headers':headers} return Partay.post('/in', ) end |
.hopOut(x) ⇒ Object
98 99 100 101 102 |
# File 'lib/wordhop.rb', line 98 def hopOut(x) puts 'hopOut' = {'body':x, 'headers':headers} return Partay.post('/out', ) end |
.initialize ⇒ Object
19 20 21 22 23 24 |
# File 'lib/wordhop.rb', line 19 def initialize @apikey @clientkey @token @platform end |
.logUnknownIntent(x) ⇒ Object
104 105 106 107 108 |
# File 'lib/wordhop.rb', line 104 def logUnknownIntent(x) puts 'logUnknownIntent' = {'body':x, 'headers':headers} return Partay.post('/unknown', ) end |
.new(*args, &block) ⇒ Object
26 27 28 29 30 |
# File 'lib/wordhop.rb', line 26 def new(*args, &block) obj = allocate obj.initialize(*args, &block) obj end |
.on(event, &block) ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/wordhop.rb', line 77 def on(event, &block) unless EVENTS.include? event raise ArgumentError, "#{event} is not a valid event; " \ "available events are #{EVENTS.join(',')}" end hooks[event] = block end |
.trigger(event, *args) ⇒ Object
86 87 88 89 90 |
# File 'lib/wordhop.rb', line 86 def trigger(event, *args) hooks.fetch(event).call(*args) rescue KeyError $stderr.puts "Ignoring #{event} (no hook registered)" end |