Class: Symbol
- 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
-
#/(o) ⇒ String
Join with o as a file path.
- #duplicable? ⇒ Boolean
- #methodize ⇒ Object
-
#to_json(options = {}) ⇒ Object
:nodoc:.
-
#to_proc ⇒ Object
Turns the symbol into a simple proc, which is especially useful for enumerations.
- #try_dup ⇒ Object
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"
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
28 29 30 |
# File 'lib/gems/activesupport-2.2.2/lib/active_support/core_ext/duplicable.rb', line 28 def duplicable? false end |
#methodize ⇒ Object
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( = {}) #:nodoc: ActiveSupport::JSON.encode(to_s, ) end |
#to_proc ⇒ Object
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_dup ⇒ Object
3 4 5 |
# File 'lib/gems/extlib-0.9.9/lib/extlib/symbol.rb', line 3 def try_dup self end |