module Wordhop

Constants

EVENTS

Attributes

apikey[RW]
clientkey[RW]
platform[RW]
token[RW]

Public Class Methods

assistanceRequested(x) click to toggle source
# File lib/wordhop.rb, line 114
def assistanceRequested(x)
    puts 'assistanceRequested'
    options = {'body':x, 'headers':headers}
    return Partay.post('/human', options)
end
headers() click to toggle source
# File lib/wordhop.rb, line 49
def headers
    @headers = {'apikey':apikey,'clientkey':clientkey,'platform':platform, 'token': token}
end
hooks() click to toggle source
# File lib/wordhop.rb, line 53
def hooks
    @hooks ||= {}
end
hopIn(x) click to toggle source
# File lib/wordhop.rb, line 96
def hopIn(x)
    puts 'hopIn'
    options = {'body':x, 'headers':headers}
    return Partay.post('/in', options)
end
hopOut(x) click to toggle source
# File lib/wordhop.rb, line 102
def hopOut(x)
    puts 'hopOut'
    options = {'body':x, 'headers':headers}
    return Partay.post('/out', options)
end
initialize() click to toggle source
# File lib/wordhop.rb, line 19
def initialize
    @apikey
    @clientkey
    @token
    @platform
end
logUnknownIntent(x) click to toggle source
# File lib/wordhop.rb, line 108
def logUnknownIntent(x)
    puts 'logUnknownIntent'
    options = {'body':x, 'headers':headers}
    return Partay.post('/unknown', options)
end
new(*args, &block) click to toggle source
# File lib/wordhop.rb, line 26
def new(*args, &block)
    obj = allocate
    obj.initialize(*args, &block)
    obj
end
on(event, &block) click to toggle source
# File lib/wordhop.rb, line 81
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) click to toggle source
# File lib/wordhop.rb, line 90
def trigger(event, *args)
    hooks.fetch(event).call(*args)
rescue KeyError
    $stderr.puts "Ignoring #{event} (no hook registered)"
end