Class: MimeType

Inherits:
Object
  • Object
show all
Defined in:
lib/yodel/mime_types/mime_type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject

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_builderObject



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_typeObject



25
26
27
# File 'lib/yodel/mime_types/mime_type.rb', line 25

def default_mime_type
  @mime_types.first
end

#has_builder?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/yodel/mime_types/mime_type.rb', line 29

def has_builder?
  !@builder.nil?
end

#has_processor?Boolean

Returns:

  • (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