class Shoutout::Headers
Public Class Methods
new(constructor = {})
click to toggle source
Calls superclass method
# File lib/shoutout/headers.rb, line 13 def initialize(constructor = {}) if constructor.is_a?(Hash) super() update(constructor) else super(constructor) end end
parse(raw_headers)
click to toggle source
# File lib/shoutout/headers.rb, line 3 def self.parse(raw_headers) headers = {} raw_headers.split($/).each do |line| key, value = line.chomp.split(":", 2) headers[key.strip] = value.strip end new(headers) end
Public Instance Methods
[](key)
click to toggle source
Calls superclass method
# File lib/shoutout/headers.rb, line 39 def [](key) super(convert_key(key)) end
[]=(key, value)
click to toggle source
# File lib/shoutout/headers.rb, line 43 def []=(key, value) regular_writer(convert_key(key), value) end
Also aliased as: regular_writer, store
delete(key)
click to toggle source
Calls superclass method
# File lib/shoutout/headers.rb, line 57 def delete(key) super(convert_key(key)) end
key?(key)
click to toggle source
Calls superclass method
# File lib/shoutout/headers.rb, line 49 def key?(key) super(convert_key(key)) end
update(other_hash) { |convert_key(key), self, value| ... }
click to toggle source
Calls superclass method
# File lib/shoutout/headers.rb, line 25 def update(other_hash) if other_hash.is_a?(Headers) super(other_hash) else other_hash.each_pair do |key, value| if block_given? && has_key?(key) value = yield(convert_key(key), self[key], value) end self[key] = value end self end end
Also aliased as: regular_update
Private Instance Methods
convert_key(key)
click to toggle source
# File lib/shoutout/headers.rb, line 62 def convert_key(key) (key.kind_of?(Symbol) ? key.to_s.gsub(/_/, "-") : key).downcase end