Class: Swaggable::MimeTypeDefinition
- Inherits:
-
Object
- Object
- Swaggable::MimeTypeDefinition
- Defined in:
- lib/swaggable/mime_type_definition.rb
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
- #http_string ⇒ Object
-
#initialize(id) ⇒ MimeTypeDefinition
constructor
A new instance of MimeTypeDefinition.
- #inspect ⇒ Object
- #name ⇒ Object (also: #to_s)
- #to_sym ⇒ Object
Constructor Details
#initialize(id) ⇒ MimeTypeDefinition
Returns a new instance of MimeTypeDefinition.
3 4 5 6 7 8 9 |
# File 'lib/swaggable/mime_type_definition.rb', line 3 def initialize id @type, @subtype, @options = case id when String then parse_string id when Symbol then parse_symbol id else raise "#{id.inspect} not valid" end end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
37 38 39 40 41 42 43 |
# File 'lib/swaggable/mime_type_definition.rb', line 37 def == other case other when self.class then name == other.name when String, Symbol then name == self.class.new(other).name else false end end |
#hash ⇒ Object
47 48 49 |
# File 'lib/swaggable/mime_type_definition.rb', line 47 def hash name.hash end |
#http_string ⇒ Object
17 18 19 20 21 |
# File 'lib/swaggable/mime_type_definition.rb', line 17 def http_string http = name http += if http end |
#inspect ⇒ Object
33 34 35 |
# File 'lib/swaggable/mime_type_definition.rb', line 33 def inspect "#<Swaggable::ContentTypeDefinition: #{type}/#{subtype}>" end |
#name ⇒ Object Also known as: to_s
11 12 13 |
# File 'lib/swaggable/mime_type_definition.rb', line 11 def name "#{type}/#{subtype}" end |
#to_sym ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/swaggable/mime_type_definition.rb', line 23 def to_sym string = if type == 'application' subtype else name end string.gsub(/[-\.\/]+/,'_').to_sym end |