class Ralyxa::Handler

Attributes

request[R]

Public Class Methods

new(request) click to toggle source
# File lib/ralyxa/handler.rb, line 7
def initialize(request)
  @request = request
end

Public Instance Methods

audio_player() click to toggle source
# File lib/ralyxa/handler.rb, line 30
def audio_player
  Ralyxa::ResponseEntities::Directives::AudioPlayer
end
card(title, body, image_url = nil, card_class = Ralyxa::ResponseEntities::Card) click to toggle source
# File lib/ralyxa/handler.rb, line 26
def card(title, body, image_url = nil, card_class = Ralyxa::ResponseEntities::Card)
  card_class.as_hash(title, body, image_url)
end
handle() click to toggle source
# File lib/ralyxa/handler.rb, line 11
def handle
  raise NotImplementedError
end
log(level, message) click to toggle source
# File lib/ralyxa/handler.rb, line 38
def log(level, message)
  puts "[#{Time.new}] [#{@request.user_id}] #{level} - #{message}"
end

Private Instance Methods

ask(response_text = '', response_details = {}, response_builder = Ralyxa::ResponseBuilder)
Alias for: respond
respond(response_text = '', response_details = {}, response_builder = Ralyxa::ResponseBuilder) click to toggle source
# File lib/ralyxa/handler.rb, line 15
def respond(response_text = '', response_details = {}, response_builder = Ralyxa::ResponseBuilder)
  options = response_details
  options[:response_text] = response_text if response_text

  response_builder.build(options)
end
Also aliased as: ask
tell(response_text = '', response_details = {}) click to toggle source
# File lib/ralyxa/handler.rb, line 22
def tell(response_text = '', response_details = {})
  respond(response_text, response_details.merge(end_session: true))
end