Sha256: 2adcf0a71515916b2d522c54811635d733d21c65510f0c0164f9a0fc96bf9355

Contents?: true

Size: 907 Bytes

Versions: 10

Compression:

Stored size: 907 Bytes

Contents

module Punchblock
  class Event
    class End < Event
      register :end, :core

      ##
      # Create an End event
      #
      # @param [Hash] options
      # @option options [String, Optional] :reason the end reason
      #
      # @return [Event::End] a formatted Rayo end event
      #
      def self.new(options = {})
        super().tap do |new_node|
          case options
          when Nokogiri::XML::Node
            new_node.inherit options
          when Hash
            options.each_pair { |k,v| new_node.send :"#{k}=", v }
          end
        end
      end

      def reason
        children.select { |c| c.is_a? Nokogiri::XML::Element }.first.name.to_sym
      end

      def reason=(other)
        self << Nokogiri::XML::Element.new(other.to_s, self.document)
      end

      def inspect_attributes # :nodoc:
        [:reason] + super
      end
    end # End
  end
end # Punchblock

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
punchblock-0.8.3 lib/punchblock/event/end.rb
punchblock-0.8.2 lib/punchblock/event/end.rb
punchblock-0.8.1 lib/punchblock/event/end.rb
punchblock-0.8.0 lib/punchblock/event/end.rb
punchblock-0.7.2 lib/punchblock/event/end.rb
punchblock-0.7.1 lib/punchblock/event/end.rb
punchblock-0.7.0 lib/punchblock/event/end.rb
punchblock-0.6.2 lib/punchblock/event/end.rb
punchblock-0.6.1 lib/punchblock/event/end.rb
punchblock-0.6.0 lib/punchblock/event/end.rb