Class: UnknownClass
- Defined in:
- lib/unknown.rb,
lib/unknown/version.rb
Overview
A numeric class that encapsulates the idea of an unknown number. Any math operation that includes an unknown is also Unknown this allows complex math functions to run without throwing execptions but the end result will be unknown if any of the values in the formula are also Unknown
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Method Summary collapse
- #<=>(_) ⇒ Object
- #coerce(_) ⇒ Object
- #divmod(_) ⇒ Object
- #if_known?(&block) ⇒ Boolean
- #if_unknown?(value = nil, &block) ⇒ Boolean
- #inspect(*_) ⇒ Object (also: #to_s)
- #round(_ = nil) ⇒ Object
- #unknown? ⇒ Boolean
Methods inherited from Numeric
Instance Method Details
#<=>(_) ⇒ Object
81 82 83 |
# File 'lib/unknown.rb', line 81 def <=>(_) nil end |
#coerce(_) ⇒ Object
32 33 34 |
# File 'lib/unknown.rb', line 32 def coerce(_) [self, self] end |
#divmod(_) ⇒ Object
40 41 42 |
# File 'lib/unknown.rb', line 40 def divmod(_) [self, self] end |
#if_known?(&block) ⇒ Boolean
23 24 25 |
# File 'lib/unknown.rb', line 23 def if_known?(&block) self end |
#if_unknown?(value = nil, &block) ⇒ Boolean
15 16 17 18 19 20 21 |
# File 'lib/unknown.rb', line 15 def if_unknown?(value=nil, &block) if block_given? yield else value end end |
#inspect(*_) ⇒ Object Also known as: to_s
27 28 29 |
# File 'lib/unknown.rb', line 27 def inspect(*_) "Unknown" end |
#round(_ = nil) ⇒ Object
36 37 38 |
# File 'lib/unknown.rb', line 36 def round(_=nil) self end |
#unknown? ⇒ Boolean
11 12 13 |
# File 'lib/unknown.rb', line 11 def unknown? true end |