<commit_before>module Punchblock
  module Component
    module Tropo
      class Conference < ComponentNode
        register :conference, :conference

        ##
        # Creates an Rayo conference command
        #
        # @param [Hash] options
        # @option options [String] :name room id to with which to create or join the conference
        # @option options [Announcement, Hash, Optional] :announcement to play on entry
        # @option options [Music, Hash, Optional] :music to play to the participant when no moderator is present
        # @option options [Boolean, Optional] :mute If set to true, the user will be muted in the conference
        # @option options [Boolean, Optional] :moderator Whether or not the conference should be moderated
        # @option options [Boolean, Optional] :tone_passthrough Identifies whether or not conference members can hear the tone generated when a a key on the phone is pressed.
        # @option options [String, Optional] :terminator This is the touch-tone key (also known as "DTMF digit") used to exit the conference.
        #
        # @return [Command::Conference] a formatted Rayo conference command
        #
        # @example
        #    conference :name => 'the_one_true_conference', :terminator => '#'
        #
        #    returns:
        #      <conference xmlns="urn:xmpp:tropo:conference:1" name="the_one_true_conference" terminator="#"/>
        def self.new(options = {})
          super().tap do |new_node|
            options.each_pair do |k,v|
              new_node.send :"#{k}=", v
            end
          end
        end

        ##
        # @return [String] the name of the conference
        #
        def name
          read_attr :name
        end

        ##
        # @param [String] name of the conference
        #
        def name=(name)
          write_attr :name, name
        end

        ##
        # @return [Boolean] If set to true, the user will be muted in the conference.
        #
        def mute
          read_attr(:mute) == 'true'
        end

        ##
        # @param [Boolean] mute If set to true, the user will be muted in the conference
        #
        def mute=(mute)
          write_attr :mute, mute.to_s
        end

        ##
        # @return [String] This is the touch-tone key (also known as "DTMF digit") used to exit the conference.
        #
        def terminator
          read_attr :terminator
        end

        ##
        # @param [String] terminator This is the touch-tone key (also known as "DTMF digit") used to exit the conference.
        #
        def terminator=(terminator)
          write_attr :terminator, terminator
        end

        ##
        # @return [Boolean] Identifies whether or not conference members can hear the tone generated when a a key on the phone is pressed.
        #
        def tone_passthrough
          read_attr('tone-passthrough') == 'true'
        end

        ##
        # @param [Boolean] tone_passthrough Identifies whether or not conference members can hear the tone generated when a a key on the phone is pressed.
        #
        def tone_passthrough=(tone_passthrough)
          write_attr 'tone-passthrough', tone_passthrough.to_s
        end

        ##
        # @return [Boolean] Whether or not the conference should be moderated
        #
        def moderator
          read_attr(:moderator) == 'true'
        end

        ##
        # @param [Boolean] moderator Whether or not the conference should be moderated
        #
        def moderator=(moderator)
          write_attr :moderator, moderator.to_s
        end

        ##
        # @return [Announcement] the announcement to play to the participant on entry
        #
        def announcement
          node = find_first '//ns:announcement', :ns => self.registered_ns
          Announcement.new node if node
        end

        ##
        # @param [Announcement, Hash] ann
        # @option ann [String] :text Text to speak to the caller as an announcement
        # @option ann [String] :url URL to play to the caller as an announcement
        #
        def announcement=(ann)
          ann = Announcement.new(ann) unless ann.is_a? Announcement
          self << ann
        end

        ##
        # @return [Music] the music to play to the participant on entry if there's no moderator present
        #
        def music
          node = find_first '//ns:music', :ns => self.registered_ns
          Music.new node if node
        end

        ##
        # @param [Music, Hash] m
        # @option m [String] :text Text to speak to the caller
        # @option m [String] :url URL to play to the caller
        #
        def music=(m)
          m = Music.new(m) unless m.is_a? Announcement
          self << m
        end

        def inspect_attributes # :nodoc:
          [:name, :mute, :terminator, :tone_passthrough, :moderator, :announcement, :music] + super
        end

        def transition_state!(event)
          super
          case event
          when OnHold
            onhold!
          when OffHold
            offhold!
          end
        end

        state_machine :state do
          after_transition :new => :requested do |command, transition|
            command.mute ? command.muted! : command.unmuted!
          end
        end

        state_machine :mute_status, :initial => :unknown_mute do
          event :muted do
            transition [:unmuted, :unknown_mute] => :muted
          end

          event :unmuted do
            transition [:muted, :unknown_mute] => :unmuted
          end
        end

        state_machine :hold_status, :initial => :unknown_hold do
          event :onhold do
            transition [:offhold, :unknown_hold] => :onhold
          end

          event :offhold do
            transition [:onhold, :unknown_hold] => :offhold
          end
        end

        class Announcement < MediaNode
          register :announcement, :conference
        end

        class Music < MediaNode
          register :music, :conference
        end

        class OnHold < Event
          register :'on-hold', :conference
        end

        class OffHold < Event<commit_msg>Fix a silly constant lookup bug<commit_after>module Punchblock
  module Component
    module Tropo
      class Conference < ComponentNode
        register :conference, :conference

        ##
        # Creates an Rayo conference command
        #
        # @param [Hash] options
        # @option options [String] :name room id to with which to create or join the conference
        # @option options [Announcement, Hash, Optional] :announcement to play on entry
        # @option options [Music, Hash, Optional] :music to play to the participant when no moderator is present
        # @option options [Boolean, Optional] :mute If set to true, the user will be muted in the conference
        # @option options [Boolean, Optional] :moderator Whether or not the conference should be moderated
        # @option options [Boolean, Optional] :tone_passthrough Identifies whether or not conference members can hear the tone generated when a a key on the phone is pressed.
        # @option options [String, Optional] :terminator This is the touch-tone key (also known as "DTMF digit") used to exit the conference.
        #
        # @return [Command::Conference] a formatted Rayo conference command
        #
        # @example
        #    conference :name => 'the_one_true_conference', :terminator => '#'
        #
        #    returns:
        #      <conference xmlns="urn:xmpp:tropo:conference:1" name="the_one_true_conference" terminator="#"/>
        def self.new(options = {})
          super().tap do |new_node|
            options.each_pair do |k,v|
              new_node.send :"#{k}=", v
            end
          end
        end

        ##
        # @return [String] the name of the conference
        #
        def name
          read_attr :name
        end

        ##
        # @param [String] name of the conference
        #
        def name=(name)
          write_attr :name, name
        end

        ##
        # @return [Boolean] If set to true, the user will be muted in the conference.
        #
        def mute
          read_attr(:mute) == 'true'
        end

        ##
        # @param [Boolean] mute If set to true, the user will be muted in the conference
        #
        def mute=(mute)
          write_attr :mute, mute.to_s
        end

        ##
        # @return [String] This is the touch-tone key (also known as "DTMF digit") used to exit the conference.
        #
        def terminator
          read_attr :terminator
        end

        ##
        # @param [String] terminator This is the touch-tone key (also known as "DTMF digit") used to exit the conference.
        #
        def terminator=(terminator)
          write_attr :terminator, terminator
        end

        ##
        # @return [Boolean] Identifies whether or not conference members can hear the tone generated when a a key on the phone is pressed.
        #
        def tone_passthrough
          read_attr('tone-passthrough') == 'true'
        end

        ##
        # @param [Boolean] tone_passthrough Identifies whether or not conference members can hear the tone generated when a a key on the phone is pressed.
        #
        def tone_passthrough=(tone_passthrough)
          write_attr 'tone-passthrough', tone_passthrough.to_s
        end

        ##
        # @return [Boolean] Whether or not the conference should be moderated
        #
        def moderator
          read_attr(:moderator) == 'true'
        end

        ##
        # @param [Boolean] moderator Whether or not the conference should be moderated
        #
        def moderator=(moderator)
          write_attr :moderator, moderator.to_s
        end

        ##
        # @return [Announcement] the announcement to play to the participant on entry
        #
        def announcement
          node = find_first '//ns:announcement', :ns => self.registered_ns
          Announcement.new node if node
        end

        ##
        # @param [Announcement, Hash] ann
        # @option ann [String] :text Text to speak to the caller as an announcement
        # @option ann [String] :url URL to play to the caller as an announcement
        #
        def announcement=(ann)
          ann = Announcement.new(ann) unless ann.is_a? Announcement
          self << ann
        end

        ##
        # @return [Music] the music to play to the participant on entry if there's no moderator present
        #
        def music
          node = find_first '//ns:music', :ns => self.registered_ns
          Music.new node if node
        end

        ##
        # @param [Music, Hash] m
        # @option m [String] :text Text to speak to the caller
        # @option m [String] :url URL to play to the caller
        #
        def music=(m)
          m = Music.new(m) unless m.is_a? Announcement
          self << m
        end

        class Announcement < MediaNode
          register :announcement, :conference
        end

        class Music < MediaNode
          register :music, :conference
        end

        def inspect_attributes # :nodoc:
          [:name, :mute, :terminator, :tone_passthrough, :moderator, :announcement, :music] + super
        end

        def transition_state!(event)
          super
          case event
          when OnHold
            onhold!
          when OffHold
            offhold!
          end
        end

        state_machine :state do
          after_transition :new => :requested do |command, transition|
            command.mute ? command.muted! : command.unmuted!
          end
        end

        state_machine :mute_status, :initial => :unknown_mute do
          event :muted do
            transition [:unmuted, :unknown_mute] => :muted
          end

          event :unmuted do
            transition [:muted, :unknown_mute] => :unmuted
          end
        end

        state_machine :hold_status, :initial => :unknown_hold do
          event :onhold do
            transition [:offhold, :unknown_hold] => :onhold
          end

          event :offhold do
            transition [:onhold, :unknown_hold] => :offhold
          end
        end

        class OnHold < Event
          register :'on-hold', :conference
        end

        class OffHold < Event
{'fraction_non_alphanumeric': 0.07697283311772316, 'fraction_numerical': 0.00016170763260025875, 'mean_word_length': 1.8149749658625398, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '123674', 'n_tokens_mistral': 3386, 'n_tokens_neox': 3281, 'n_words': 1198}