Class: Cardiac::Representation::Reflection
- Inherits:
-
Struct
- Object
- Struct
- Cardiac::Representation::Reflection
- Defined in:
- lib/cardiac/representation.rb
Overview
Basic reflection of a representation type.
Instance Attribute Summary collapse
-
#coder ⇒ Object
Returns the value of attribute coder.
-
#default_type ⇒ Object
Returns the value of attribute default_type.
-
#extension ⇒ Object
Returns the value of attribute extension.
-
#types ⇒ Object
Returns the value of attribute types.
Instance Method Summary collapse
- #__codecs__ ⇒ Object
-
#initialize(extension, default_type = nil, *extra_types) ⇒ Reflection
constructor
A new instance of Reflection.
- #matches?(mime_type) ⇒ Boolean
Constructor Details
#initialize(extension, default_type = nil, *extra_types) ⇒ Reflection
Returns a new instance of Reflection.
37 38 39 40 41 42 43 44 45 |
# File 'lib/cardiac/representation.rb', line 37 def initialize(extension,default_type=nil,*extra_types) types = __codecs__.mimes_for(extension) + extra_types if default_type.nil? default_type = types.first elsif ! types.include? default_type types.unshift default_type end super extension.to_sym, types, default_type, __codecs__.coder_for(extension) end |
Instance Attribute Details
#coder ⇒ Object
Returns the value of attribute coder
36 37 38 |
# File 'lib/cardiac/representation.rb', line 36 def coder @coder end |
#default_type ⇒ Object
Returns the value of attribute default_type
36 37 38 |
# File 'lib/cardiac/representation.rb', line 36 def default_type @default_type end |
#extension ⇒ Object
Returns the value of attribute extension
36 37 38 |
# File 'lib/cardiac/representation.rb', line 36 def extension @extension end |
#types ⇒ Object
Returns the value of attribute types
36 37 38 |
# File 'lib/cardiac/representation.rb', line 36 def types @types end |
Instance Method Details
#__codecs__ ⇒ Object
54 55 56 |
# File 'lib/cardiac/representation.rb', line 54 def __codecs__ @__codecs__ ||= ::Cardiac::Representation::Codecs end |
#matches?(mime_type) ⇒ Boolean
50 51 52 |
# File 'lib/cardiac/representation.rb', line 50 def matches?(mime_type) types.any?{|type| type.like? mime_type} end |