Class: Quadratic::Imag
- Inherits:
-
Object
- Object
- Quadratic::Imag
- Defined in:
- lib/quadratic_number/imag.rb
Overview
< Quadratic < Numeric
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#real? ⇒ Boolean
defined by Numeric: * integer? #=> false.
-
#to_c ⇒ Object
Type conversions ###.
Instance Method Details
#==(other) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/quadratic_number/imag.rb', line 22 def ==(other) if other.kind_of?(Numeric) self.to_c - other == 0 else other == self end end |
#real? ⇒ Boolean
defined by Numeric:
-
integer? #=> false
9 10 11 |
# File 'lib/quadratic_number/imag.rb', line 9 def real? false end |
#to_c ⇒ Object
Type conversions ###
38 39 40 41 42 43 44 45 46 |
# File 'lib/quadratic_number/imag.rb', line 38 def to_c d = self.class::D if d == -1 Complex.rect(@a, @b) else rev_class = Quadratic[-d] Complex.rect(@a, rev_class.new(0, @b)) end end |