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, options) ⇒ ResponseBuilder

Returns a new instance of ResponseBuilder.



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

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

Class Method Details

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



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

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

Instance Method Details

#buildObject



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

def build
  merge_output_speech if response_text_exists?
  merge_card if card_exists?

  @response_class.as_hash(@options).to_json
end