Class: HttpHeaders::Link::Entry
- Inherits:
-
Object
- Object
- HttpHeaders::Link::Entry
- Defined in:
- lib/http_headers/link.rb
Instance Attribute Summary collapse
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #[](parameter) ⇒ Object
-
#initialize(href, index:, parameters:) ⇒ Entry
constructor
A new instance of Entry.
-
#rel ⇒ Object
noinspection RubyInstanceMethodNamingConvention.
- #to_header ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(href, index:, parameters:) ⇒ Entry
Returns a new instance of Entry.
19 20 21 22 23 24 25 |
# 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 |
Instance Attribute Details
#href ⇒ Object
Returns the value of attribute href.
27 28 29 |
# File 'lib/http_headers/link.rb', line 27 def href @href end |
#index ⇒ Object
Returns the value of attribute index.
27 28 29 |
# File 'lib/http_headers/link.rb', line 27 def index @index end |
Instance Method Details
#<=>(other) ⇒ Object
34 35 36 |
# File 'lib/http_headers/link.rb', line 34 def <=>(other) index <=> other.index end |
#[](parameter) ⇒ Object
38 39 40 |
# File 'lib/http_headers/link.rb', line 38 def [](parameter) parameters.fetch(String(parameter).to_sym) end |
#rel ⇒ Object
noinspection RubyInstanceMethodNamingConvention
30 31 32 |
# File 'lib/http_headers/link.rb', line 30 def rel parameters.fetch(:rel) { nil } end |
#to_header ⇒ Object
42 43 44 |
# File 'lib/http_headers/link.rb', line 42 def to_header to_s end |
#to_s ⇒ Object
46 47 48 |
# File 'lib/http_headers/link.rb', line 46 def to_s ["<#{href}>"].concat(parameters.map { |k, v| "#{k}=#{v}" }).compact.reject(&:empty?).join('; ') end |