class HttpHeaders::Accept::Entry
Attributes
index[RW]
media_type[RW]
parameters[RW]
Public Class Methods
new(media_type, index:, parameters:)
click to toggle source
# File lib/http_headers/accept.rb, line 11 def initialize(media_type, index:, parameters:) self.media_type = media_type self.parameters = parameters self.index = index freeze end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/http_headers/accept.rb, line 26 def <=>(other) quality = other.q <=> q return quality unless quality.zero? index <=> other.send(:index) end
[](parameter)
click to toggle source
# File lib/http_headers/accept.rb, line 32 def [](parameter) parameters.fetch(String(parameter).to_sym) end
q()
click to toggle source
noinspection RubyInstanceMethodNamingConvention
# File lib/http_headers/accept.rb, line 22 def q parameters.fetch(:q) { 1.0 }.to_f end
to_header()
click to toggle source
# File lib/http_headers/accept.rb, line 36 def to_header to_s end
to_s()
click to toggle source
# File lib/http_headers/accept.rb, line 40 def to_s [media_type].concat(parameters.map { |k, v| "#{k}=#{v}" }).compact.reject(&:empty?).join('; ') end