class Swaggable::MimeTypeDefinition
Attributes
options[R]
subtype[R]
type[R]
Public Class Methods
new(id)
click to toggle source
# 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
Public Instance Methods
==(other)
click to toggle source
# 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
Also aliased as: eql?
hash()
click to toggle source
# File lib/swaggable/mime_type_definition.rb, line 47 def hash name.hash end
http_string()
click to toggle source
# File lib/swaggable/mime_type_definition.rb, line 17 def http_string http = name http += options if options http end
inspect()
click to toggle source
# File lib/swaggable/mime_type_definition.rb, line 33 def inspect "#<Swaggable::ContentTypeDefinition: #{type}/#{subtype}>" end
name()
click to toggle source
# File lib/swaggable/mime_type_definition.rb, line 11 def name "#{type}/#{subtype}" end
Also aliased as: to_s
to_sym()
click to toggle source
# 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
Private Instance Methods
parse_string(id)
click to toggle source
# File lib/swaggable/mime_type_definition.rb, line 55 def parse_string id type, subtype, options = id.match(/(?<type>[^\/]+)\/?(?<subtype>[^;]*)(?<options>.*)/).captures type = nil if type == "" subtype = nil if subtype == "" options = nil if options == "" [type, subtype, options] end
parse_symbol(id)
click to toggle source
# File lib/swaggable/mime_type_definition.rb, line 65 def parse_symbol id type = 'application' subtype = id.to_s.gsub('_','-') options = nil [type, subtype, options] end