Class: Symbol
- Defined in:
- lib/y_support/misc/respond_to.rb,
lib/y_support/core_ext/symbol/misc.rb
Instance Method Summary collapse
-
#default!(default_symbol) ⇒ Object
This method applies String#default! method to the receiver converted to a string.
-
#to_standardized_sym ⇒ Object
Applies String#to_standardized_sym method to the recevier converted to a string.
-
#~@ ⇒ Object
Creates a RespondTo object from the receiver symbol.
Instance Method Details
#default!(default_symbol) ⇒ Object
This method applies String#default! method to the receiver converted to a string. Of course, symbols are immutable, so in spite of the exclamation mark in the method name, a new symbol (supplied as argument) is returned, if the original one is considered “defaulted” (otherwise, original symbol is returned unchanged).
10 11 12 |
# File 'lib/y_support/core_ext/symbol/misc.rb', line 10 def default! default_symbol to_s.default!( default_symbol ).to_sym end |
#to_standardized_sym ⇒ Object
Applies String#to_standardized_sym method to the recevier converted to a string.
17 18 19 |
# File 'lib/y_support/core_ext/symbol/misc.rb', line 17 def to_standardized_sym to_s.to_standardized_sym end |
#~@ ⇒ Object
Creates a RespondTo object from the receiver symbol. Intended use for this is nin case statements: RespondTo has customized #=== method, that calls #respond_to? to determine the return value.
For example, when ~:each
in a case statement is valid only if the tested object respond_to?( :each ) returns true.
29 |
# File 'lib/y_support/misc/respond_to.rb', line 29 def ~@; RespondTo self end |