Class: Proc
- Inherits:
-
Object
- Object
- Proc
- Defined in:
- lib/totally_lazy/either.rb,
lib/totally_lazy/option.rb,
lib/totally_lazy/functions.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.compose(f, g) ⇒ Object
5 6 7 |
# File 'lib/totally_lazy/functions.rb', line 5 def self.compose(f, g) lambda { |*args| f[g[*args]] } end |
Instance Method Details
#*(g) ⇒ Object
9 10 11 |
# File 'lib/totally_lazy/functions.rb', line 9 def *(g) Proc.compose(self, g) end |
#and_then(g) ⇒ Object
13 14 15 |
# File 'lib/totally_lazy/functions.rb', line 13 def and_then(g) Proc.compose(g, self) end |
#optional ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/totally_lazy/option.rb', line 4 def optional ->(value) { begin Option.option(self.(value)) rescue Option.none end } end |
#or_exception ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/totally_lazy/either.rb', line 4 def or_exception -> (value) { begin right(self.(value)) rescue Exception => e left(e) end } end |