Module: VV::ComplexMethods
- Included in:
- Complex
- Defined in:
- lib/vv/complex_methods.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
4 5 6 |
# File 'lib/vv/complex_methods.rb', line 4 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#non_imaginary! ⇒ Object
26 27 28 29 |
# File 'lib/vv/complex_methods.rb', line 26 def non_imaginary! = "Complex number contains imaginary part." fail if imaginary? end |
#real_digits(unsafe: false) ⇒ Object
21 22 23 24 |
# File 'lib/vv/complex_methods.rb', line 21 def real_digits unsafe: false self.non_imaginary! unless unsafe self.real.to_d.to_digits end |
#to_d ⇒ Object
16 17 18 19 |
# File 'lib/vv/complex_methods.rb', line 16 def to_d self.non_imaginary! self.real.to_f.to_d end |