Class: Deterministic::Option
Class Method Summary collapse
Class Method Details
.any?(expr) ⇒ Boolean
13 14 15 |
# File 'lib/deterministic/option.rb', line 13 def any?(expr) to_option(expr) { expr.nil? || not(expr.respond_to?(:empty?)) || expr.empty? } end |
.some?(expr) ⇒ Boolean
9 10 11 |
# File 'lib/deterministic/option.rb', line 9 def some?(expr) to_option(expr) { expr.nil? } end |
.to_option(expr, &predicate) ⇒ Object
17 18 19 |
# File 'lib/deterministic/option.rb', line 17 def to_option(expr, &predicate) predicate.call(expr) ? None.new : Some.new(expr) end |
.try! ⇒ Object
21 22 23 |
# File 'lib/deterministic/option.rb', line 21 def try! yield rescue None.new end |