Class: Symbol

Inherits:
Object show all
Defined in:
lib/gems/activesupport-2.2.2/lib/active_support/core_ext/duplicable.rb,
lib/mack-facets/extensions/symbol.rb,
lib/gems/extlib-0.9.9/lib/extlib/symbol.rb,
lib/gems/activesupport-2.2.2/lib/active_support/core_ext/symbol.rb,
lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/symbol.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#/(o) ⇒ String

Join with o as a file path

:merb/"core_ext"              #=> "merb/core_ext"
:merb / :core_ext / :string   #=> "merb/core_ext/string"

Parameters:

  • o (#to_s)

    The path component(s) to append.

Returns:

  • (String)

    The receiver (as path string), concatenated with o.



18
19
20
# File 'lib/gems/extlib-0.9.9/lib/extlib/symbol.rb', line 18

def /(o)
  File.join(self.to_s, o.to_s)
end

#duplicable?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/gems/activesupport-2.2.2/lib/active_support/core_ext/duplicable.rb', line 28

def duplicable?
  false
end

#methodizeObject



3
4
5
# File 'lib/mack-facets/extensions/symbol.rb', line 3

def methodize
  self.to_s.methodize
end

#to_json(options = {}) ⇒ Object

:nodoc:



2
3
4
# File 'lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/symbol.rb', line 2

def to_json(options = {}) #:nodoc:
  ActiveSupport::JSON.encode(to_s, options)
end

#to_procObject

Turns the symbol into a simple proc, which is especially useful for enumerations. Examples:

# The same as people.collect { |p| p.name }
people.collect(&:name)

# The same as people.select { |p| p.manager? }.collect { |p| p.salary }
people.select(&:manager?).collect(&:salary)


10
11
12
# File 'lib/gems/activesupport-2.2.2/lib/active_support/core_ext/symbol.rb', line 10

def to_proc
  Proc.new { |*args| args.shift.__send__(self, *args) }
end

#try_dupObject



3
4
5
# File 'lib/gems/extlib-0.9.9/lib/extlib/symbol.rb', line 3

def try_dup
  self
end