Module: Jsapi::Media::TypeAndSubtype
Overview
:nodoc:
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
- #initialize(type, subtype) ⇒ Object
- #inspect ⇒ Object
- #to_s ⇒ Object (also: #as_json)
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 |
#hash ⇒ Object
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 |
#inspect ⇒ Object
27 28 29 |
# File 'lib/jsapi/media/type_and_subtype.rb', line 27 def inspect "#<#{self.class} #{to_s.inspect}>" end |
#to_s ⇒ Object 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 |