class Ralyxa::ResponseEntities::OutputSpeech

Constants

DEFAULT_RESPONSE_SSML
DEFAULT_RESPONSE_TEXT

Public Class Methods

as_hash(speech: nil, ssml: false) click to toggle source
# File lib/ralyxa/response_entities/output_speech.rb, line 18
def self.as_hash(speech: nil, ssml: false)
  new(speech, ssml).to_h
end
new(speech, ssml) click to toggle source
# File lib/ralyxa/response_entities/output_speech.rb, line 7
def initialize(speech, ssml)
  @speech = speech
  @ssml   = ssml
end

Public Instance Methods

to_h() click to toggle source
# 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

Private Instance Methods

add_plaintext(output_speech) click to toggle source
# File lib/ralyxa/response_entities/output_speech.rb, line 29
def add_plaintext(output_speech)
  output_speech[:type] = 'PlainText'
  output_speech[:text] = (@speech || DEFAULT_RESPONSE_TEXT)
end
add_ssml(output_speech) click to toggle source
# File lib/ralyxa/response_entities/output_speech.rb, line 24
def add_ssml(output_speech)
  output_speech[:type] = 'SSML'
  output_speech[:ssml] = (@speech || DEFAULT_RESPONSE_SSML)
end