Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/functional_support/core_ext/string.rb
Instance Method Summary collapse
-
#append_until(content = " ", &condition) ⇒ Object
Appends crap to the string until the given string satisfies the given condition.
- #consume(diet = "") ⇒ Object
- #prepend_until(content = " ", &condition) ⇒ Object
Instance Method Details
#append_until(content = " ", &condition) ⇒ Object
Appends crap to the string until the given string satisfies the given condition
4 5 6 7 |
# File 'lib/functional_support/core_ext/string.rb', line 4 def append_until(content=" ", &condition) return self if yield self (self + content).append_until(content, &condition) end |
#consume(diet = "") ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/functional_support/core_ext/string.rb', line 14 def consume(diet="") return self if diet.blank? or self.blank? if self[0] == diet[0] self[1..-1].consume diet[1..-1] else throw "Mismatched diet error #{diet} does not match #{self}" end end |
#prepend_until(content = " ", &condition) ⇒ Object
9 10 11 12 |
# File 'lib/functional_support/core_ext/string.rb', line 9 def prepend_until(content=" ", &condition) return self if yield self (content + self).prepend_until(content, &condition) end |