Module: Jsapi::Media::TypeAndSubtype

Included in:
Range, Type
Defined in:
lib/jsapi/media/type_and_subtype.rb

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
8
# File 'lib/jsapi/media/type_and_subtype.rb', line 6

def self.included(base)
  base.attr_reader :type, :subtype
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



15
16
17
18
19
# File 'lib/jsapi/media/type_and_subtype.rb', line 15

def ==(other)
  other.is_a?(self.class) &&
    type == other.type &&
    subtype == other.subtype
end

#hashObject



23
24
25
# File 'lib/jsapi/media/type_and_subtype.rb', line 23

def hash
  @hash ||= [type, subtype].hash
end

#initialize(type, subtype) ⇒ Object



10
11
12
13
# File 'lib/jsapi/media/type_and_subtype.rb', line 10

def initialize(type, subtype)
  @type = type.downcase
  @subtype = subtype.downcase
end

#inspectObject



27
28
29
# File 'lib/jsapi/media/type_and_subtype.rb', line 27

def inspect
  "#<#{self.class} #{to_s.inspect}>"
end

#to_sObject Also known as: as_json



31
32
33
# File 'lib/jsapi/media/type_and_subtype.rb', line 31

def to_s
  @to_s ||= "#{type}/#{subtype}"
end