class HttpHeaders::Link::Entry

Attributes

href[RW]
index[RW]
parameters[RW]

Public Class Methods

new(href, index:, parameters:) click to toggle source
# File lib/http_headers/link.rb, line 19
def initialize(href, index:, parameters:)
  self.href = href[1...-1]
  self.parameters = parameters
  self.index = index

  freeze
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/http_headers/link.rb, line 34
def <=>(other)
  index <=> other.index
end
[](parameter) click to toggle source
# File lib/http_headers/link.rb, line 38
def [](parameter)
  parameters.fetch(String(parameter).to_sym)
end
rel() click to toggle source

noinspection RubyInstanceMethodNamingConvention

# File lib/http_headers/link.rb, line 30
def rel
  parameters.fetch(:rel) { nil }
end
to_header() click to toggle source
# File lib/http_headers/link.rb, line 42
def to_header
  to_s
end
to_s() click to toggle source
# File lib/http_headers/link.rb, line 46
def to_s
  ["<#{href}>"].concat(parameters.map { |k, v| "#{k}=#{v}" }).compact.reject(&:empty?).join('; ')
end