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.


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

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

Instance Attribute Details

#symbolObject (readonly)

Returns the value of attribute symbol


17
18
19
# File 'actionview/lib/action_view/template/types.rb', line 17

def symbol
  @symbol
end

Class Method Details

.[](type) ⇒ Object


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

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

Instance Method Details

#==(type) ⇒ Object


33
34
35
# File 'actionview/lib/action_view/template/types.rb', line 33

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

#refObject Also known as: to_sym


28
29
30
# File 'actionview/lib/action_view/template/types.rb', line 28

def ref
  @symbol
end

#to_sObject Also known as: to_str


23
24
25
# File 'actionview/lib/action_view/template/types.rb', line 23

def to_s
  @symbol.to_s
end