Class: MimeType
- Inherits:
-
Object
- Object
- MimeType
- Defined in:
- lib/yodel/mime_types/mime_type.rb
Instance Attribute Summary collapse
-
#extensions(*exts) ⇒ Object
Returns the value of attribute extensions.
-
#mime_types(*types) ⇒ Object
Returns the value of attribute mime_types.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #auth_type(*type) ⇒ Object
- #builder(&block) ⇒ Object
- #create_builder ⇒ Object
- #default_extension(ext = nil) ⇒ Object
- #default_mime_type ⇒ Object
- #has_builder? ⇒ Boolean
- #has_processor? ⇒ Boolean
-
#initialize(name) ⇒ MimeType
constructor
A new instance of MimeType.
- #layout_processor(*processor) ⇒ Object
- #process(data) ⇒ Object
- #processor(&block) ⇒ Object
Constructor Details
#initialize(name) ⇒ MimeType
Returns a new instance of MimeType.
3 4 5 6 7 8 9 10 11 |
# File 'lib/yodel/mime_types/mime_type.rb', line 3 def initialize(name) @name = name @extensions = [] @mime_types = [] @processor = nil @builder = nil @auth_type = :page @layout_processor = :ember end |
Instance Attribute Details
#extensions(*exts) ⇒ Object
Returns the value of attribute extensions.
2 3 4 |
# File 'lib/yodel/mime_types/mime_type.rb', line 2 def extensions @extensions end |
#mime_types(*types) ⇒ Object
Returns the value of attribute mime_types.
2 3 4 |
# File 'lib/yodel/mime_types/mime_type.rb', line 2 def mime_types @mime_types end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/yodel/mime_types/mime_type.rb', line 2 def name @name end |
Instance Method Details
#auth_type(*type) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/yodel/mime_types/mime_type.rb', line 61 def auth_type(*type) if type.empty? @auth_type else @auth_type = type.first end end |
#builder(&block) ⇒ Object
33 34 35 |
# File 'lib/yodel/mime_types/mime_type.rb', line 33 def builder(&block) @builder = block end |
#create_builder ⇒ Object
37 38 39 |
# File 'lib/yodel/mime_types/mime_type.rb', line 37 def create_builder @builder ? @builder.call : nil end |
#default_extension(ext = nil) ⇒ Object
21 22 23 |
# File 'lib/yodel/mime_types/mime_type.rb', line 21 def default_extension(ext=nil) @extensions.first end |
#default_mime_type ⇒ Object
25 26 27 |
# File 'lib/yodel/mime_types/mime_type.rb', line 25 def default_mime_type @mime_types.first end |
#has_builder? ⇒ Boolean
29 30 31 |
# File 'lib/yodel/mime_types/mime_type.rb', line 29 def has_builder? !@builder.nil? end |
#has_processor? ⇒ Boolean
41 42 43 |
# File 'lib/yodel/mime_types/mime_type.rb', line 41 def has_processor? !@processor.nil? end |
#layout_processor(*processor) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/yodel/mime_types/mime_type.rb', line 53 def layout_processor(*processor) if processor.empty? @layout_processor else @layout_processor = processor.first end end |
#process(data) ⇒ Object
49 50 51 |
# File 'lib/yodel/mime_types/mime_type.rb', line 49 def process(data) @processor ? @processor.call(data) : data end |
#processor(&block) ⇒ Object
45 46 47 |
# File 'lib/yodel/mime_types/mime_type.rb', line 45 def processor(&block) @processor = block end |