Class: ActionView::Template::Types::Type

Inherits:
Object
  • Object
show all
Defined in:
actionview/lib/action_view/template/types.rb

Constant Summary collapse

SET =
Struct.new(:symbols).new([ :html, :text, :js, :css, :xml, :json ])

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(symbol) ⇒ Type

Returns a new instance of Type.



21
22
23
# File 'actionview/lib/action_view/template/types.rb', line 21

def initialize(symbol)
  @symbol = symbol.to_sym
end

Instance Attribute Details

#symbolObject (readonly)

Returns the value of attribute symbol



19
20
21
# File 'actionview/lib/action_view/template/types.rb', line 19

def symbol
  @symbol
end

Class Method Details

.[](type) ⇒ Object



11
12
13
14
15
16
17
# File 'actionview/lib/action_view/template/types.rb', line 11

def self.[](type)
  if type.is_a?(self)
    type
  else
    new(type)
  end
end

Instance Method Details

#==(type) ⇒ Object



35
36
37
# File 'actionview/lib/action_view/template/types.rb', line 35

def ==(type)
  @symbol == type.to_sym unless type.blank?
end

#refObject Also known as: to_sym



30
31
32
# File 'actionview/lib/action_view/template/types.rb', line 30

def ref
  @symbol
end

#to_sObject Also known as: to_str



25
26
27
# File 'actionview/lib/action_view/template/types.rb', line 25

def to_s
  @symbol.to_s
end