Sha256: 7cd2a843cd91d9fbb2f15cbb9b92d20f321375146592cefbe6b4ec5d3b781a89

Contents?: true

Size: 992 Bytes

Versions: 6

Compression:

Stored size: 992 Bytes

Contents

module Punchblock
  class Header < RayoNode
    ##
    # @param [String] name
    # @param [String] value
    #
    def self.new(name, value = '')
      super(:header).tap do |new_node|
        case name
        when Nokogiri::XML::Node
          new_node.inherit name
        else
          new_node.name = name
          new_node.value = value
        end
      end
    end

    # The Header's name
    # @return [Symbol]
    def name
      read_attr(:name).gsub('-', '_').to_sym
    end

    # Set the Header's name
    # @param [Symbol] name the new name for the header
    def name=(name)
      write_attr :name, name.to_s.gsub('_', '-')
    end

    # The Header's value
    # @return [String]
    def value
      read_attr :value
    end

    # Set the Header's value
    # @param [String] value the new value for the header
    def value=(value)
      write_attr :value, value
    end

    def inspect_attributes # :nodoc:
      [:name, :value] + super
    end
  end
end # Punchblock

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
punchblock-0.5.1 lib/punchblock/header.rb
punchblock-0.5.0 lib/punchblock/header.rb
punchblock-0.4.3 lib/punchblock/header.rb
punchblock-0.4.2 lib/punchblock/header.rb
punchblock-0.4.1 lib/punchblock/header.rb
punchblock-0.4.0 lib/punchblock/header.rb