Class: Ralyxa::ResponseBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/ralyxa/response_builder.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response_class, output_speech_class, reprompt_class, options) ⇒ ResponseBuilder

Returns a new instance of ResponseBuilder.



6
7
8
9
10
11
# File 'lib/ralyxa/response_builder.rb', line 6

def initialize(response_class, output_speech_class, reprompt_class, options)
  @response_class      = response_class
  @output_speech_class = output_speech_class
  @reprompt_class      = reprompt_class
  @options             = options
end

Class Method Details

.build(options = {}, response_class = Ralyxa::ResponseEntities::Response, output_speech_class = Ralyxa::ResponseEntities::OutputSpeech, reprompt_class = Ralyxa::ResponseEntities::Reprompt) ⇒ Object



13
14
15
# File 'lib/ralyxa/response_builder.rb', line 13

def self.build(options = {}, response_class = Ralyxa::ResponseEntities::Response, output_speech_class = Ralyxa::ResponseEntities::OutputSpeech, reprompt_class = Ralyxa::ResponseEntities::Reprompt)
  new(response_class, output_speech_class, reprompt_class, options).build
end

Instance Method Details

#buildObject



17
18
19
20
21
22
23
# File 'lib/ralyxa/response_builder.rb', line 17

def build
  merge_output_speech if response_text_exists?
  merge_reprompt if reprompt_exists?
  merge_card if card_exists?

  @response_class.as_hash(@options).to_json
end