Class: Ralyxa::ResponseEntities::OutputSpeech

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

Constant Summary collapse

DEFAULT_RESPONSE_TEXT =
'Hello World'.freeze
DEFAULT_RESPONSE_SSML =
'<speak>Hello World</speak>'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(speech, ssml) ⇒ OutputSpeech

Returns a new instance of OutputSpeech.



7
8
9
10
# File 'lib/ralyxa/response_entities/output_speech.rb', line 7

def initialize(speech, ssml)
  @speech = speech
  @ssml   = ssml
end

Class Method Details

.as_hash(speech: nil, ssml: false) ⇒ Object



18
19
20
# File 'lib/ralyxa/response_entities/output_speech.rb', line 18

def self.as_hash(speech: nil, ssml: false)
  new(speech, ssml).to_h
end

Instance Method Details

#to_hObject



12
13
14
15
16
# File 'lib/ralyxa/response_entities/output_speech.rb', line 12

def to_h
  {}.tap do |output_speech|
    @ssml ? add_ssml(output_speech) : add_plaintext(output_speech)
  end
end