Sha256: 7b3848fcc41cede13146d2ff6dd2fb0f793d4ca4b9bd95584dbfaf2b12c4a759

Contents?: true

Size: 1.26 KB

Versions: 24

Compression:

Stored size: 1.26 KB

Contents

# encoding: utf-8

module Punchblock
  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

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
punchblock-2.0.1 lib/punchblock/component/prompt.rb
punchblock-2.0.0 lib/punchblock/component/prompt.rb
punchblock-2.0.0.beta2 lib/punchblock/component/prompt.rb
punchblock-2.0.0.beta1 lib/punchblock/component/prompt.rb