Class: Mime::Mimes

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/action_dispatch/http/mime_type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMimes

Returns a new instance of Mimes.



11
12
13
14
15
# File 'lib/action_dispatch/http/mime_type.rb', line 11

def initialize
  @mimes = []
  @symbols = []
  @symbols_set = Set.new
end

Instance Attribute Details

#symbolsObject (readonly)

Returns the value of attribute symbols.



7
8
9
# File 'lib/action_dispatch/http/mime_type.rb', line 7

def symbols
  @symbols
end

Instance Method Details

#<<(type) ⇒ Object



21
22
23
24
25
26
# File 'lib/action_dispatch/http/mime_type.rb', line 21

def <<(type)
  @mimes << type
  sym_type = type.to_sym
  @symbols << sym_type
  @symbols_set << sym_type
end

#delete_ifObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/action_dispatch/http/mime_type.rb', line 28

def delete_if
  @mimes.delete_if do |x|
    if yield x
      sym_type = x.to_sym
      @symbols.delete(sym_type)
      @symbols_set.delete(sym_type)
      true
    end
  end
end

#each(&block) ⇒ Object



17
18
19
# File 'lib/action_dispatch/http/mime_type.rb', line 17

def each(&block)
  @mimes.each(&block)
end

#valid_symbols?(symbols) ⇒ Boolean

:nodoc

Returns:

  • (Boolean)


39
40
41
# File 'lib/action_dispatch/http/mime_type.rb', line 39

def valid_symbols?(symbols) # :nodoc
  symbols.all? { |s| @symbols_set.include?(s) }
end