Class: HttpHeaders::ContentType::Entry
- Inherits:
-
Object
- Object
- HttpHeaders::ContentType::Entry
- Defined in:
- lib/http_headers/content_type.rb
Instance Attribute Summary collapse
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
Instance Method Summary collapse
- #[](parameter) ⇒ Object
-
#charset ⇒ Object
noinspection RubyInstanceMethodNamingConvention.
-
#initialize(content_type, parameters:, **_opts) ⇒ Entry
constructor
swallow index:.
- #to_header ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(content_type, parameters:, **_opts) ⇒ Entry
swallow index:
13 14 15 16 17 18 |
# File 'lib/http_headers/content_type.rb', line 13 def initialize(content_type, parameters:, **_opts) # swallow index: self.content_type = content_type self.parameters = parameters freeze end |
Instance Attribute Details
#content_type ⇒ Object
Returns the value of attribute content_type.
20 21 22 |
# File 'lib/http_headers/content_type.rb', line 20 def content_type @content_type end |
Instance Method Details
#[](parameter) ⇒ Object
27 28 29 |
# File 'lib/http_headers/content_type.rb', line 27 def [](parameter) parameters.fetch(String(parameter).to_sym) end |
#charset ⇒ Object
noinspection RubyInstanceMethodNamingConvention
23 24 25 |
# File 'lib/http_headers/content_type.rb', line 23 def charset parameters.fetch(:charset) { nil } end |
#to_header ⇒ Object
31 32 33 |
# File 'lib/http_headers/content_type.rb', line 31 def to_header to_s end |
#to_s ⇒ Object
35 36 37 |
# File 'lib/http_headers/content_type.rb', line 35 def to_s [content_type].concat(parameters.map { |k, v| "#{k}=#{v}" }).compact.reject(&:empty?).join('; ') end |