Sha256: bd321c639234ad5ee6e60371585dec87e705884c2347a529a874d744ebfe93aa

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 KB

Contents

# encoding: utf-8

module Adhearsion
  module Rayo
    module Component
      class Prompt < ComponentNode
        register :prompt, :prompt

        attribute :barge_in, Boolean
        attribute :output, Output
        attribute :input, Input

        ##
        # Create a prompt command
        #
        # @param [Output] output
        # @param [Input] input
        # @param [Hash] options
        # @option options [true, false, optional] :barge_in Indicates wether or not the input should interrupt then output
        #
        # @return [Component::Prompt] a formatted Rayo prompt command
        #
        def initialize(output = nil, input = nil, options = {})
          super options
          self.output = output
          self.input  = input
        end

        def inherit(xml_node)
          input_node = xml_node.at_xpath('ns:input', ns: Input.registered_ns)
          self.input = Input.from_xml input_node if input_node

          output_node = xml_node.at_xpath('ns:output', ns: Output.registered_ns)
          self.output = Output.from_xml output_node if output_node

          super
        end

        def rayo_attributes
          {
            'barge-in' => barge_in
          }
        end

        def rayo_children(root)
          input.to_rayo(root) if input
          output.to_rayo(root) if output
          super
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
adhearsion-3.0.0.rc1 lib/adhearsion/rayo/component/prompt.rb
adhearsion-3.0.0.beta2 lib/adhearsion/rayo/component/prompt.rb
adhearsion-3.0.0.beta1 lib/adhearsion/rayo/component/prompt.rb