Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/string_proc.rb
Overview
Adds ‘String#to_proc` to allow multiple method chain calls on each element of an enumerable using the `&` shorthand The default separator is . but can be changed with the String.proc_separator= setter
Class Attribute Summary collapse
-
.proc_separator ⇒ Object
Returns the value of attribute proc_separator.
Instance Method Summary collapse
Class Attribute Details
.proc_separator ⇒ Object
Returns the value of attribute proc_separator.
9 10 11 |
# File 'lib/string_proc.rb', line 9 def proc_separator @proc_separator end |
Instance Method Details
#to_proc ⇒ Object
12 13 14 15 16 |
# File 'lib/string_proc.rb', line 12 def to_proc proc do |object| split(self.class.proc_separator).reduce(object) { |obj, method| obj.send(method) } end end |