chg: removed all instances of Vector.method
Converted `Vector.method` calls to `self.class.method` to make extending Vector easier.
This commit is contained in:
parent
d799f8b844
commit
4df520caa1
|
@ -275,28 +275,28 @@ module Apatite
|
||||||
# `imag` as the imaginary number.
|
# `imag` as the imaginary number.
|
||||||
def coerce(klass : Complex.class, imag : Number)
|
def coerce(klass : Complex.class, imag : Number)
|
||||||
els = @elements.map { |e| Complex.new(e, imag) }
|
els = @elements.map { |e| Complex.new(e, imag) }
|
||||||
Vector.elements(els)
|
self.class.elements(els)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Attempt to coerce the elements in a vector to BigInt with
|
# Attempt to coerce the elements in a vector to BigInt with
|
||||||
# an optional `base` value.
|
# an optional `base` value.
|
||||||
def coerce(klass : BigInt.class, base = 10)
|
def coerce(klass : BigInt.class, base = 10)
|
||||||
els = @elements.map { |e| BigInt.new(e, base) }
|
els = @elements.map { |e| BigInt.new(e, base) }
|
||||||
Vector.elements(els)
|
self.class.elements(els)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Attempt to coerce the elements in a vector to BigRational
|
# Attempt to coerce the elements in a vector to BigRational
|
||||||
# with the given `denominator`.
|
# with the given `denominator`.
|
||||||
def coerce(klass : BigRational.class, denominator : Int)
|
def coerce(klass : BigRational.class, denominator : Int)
|
||||||
els = @elements.map { |e| BigRational.new(e, denominator) }
|
els = @elements.map { |e| BigRational.new(e, denominator) }
|
||||||
Vector.elements(els)
|
self.class.elements(els)
|
||||||
end
|
end
|
||||||
|
|
||||||
# The coerce method allows you to attempt to coerce the elements
|
# The coerce method allows you to attempt to coerce the elements
|
||||||
# in the matrix to another type.
|
# in the matrix to another type.
|
||||||
def coerce(klass : U.class) : Vector(U) forall U
|
def coerce(klass : U.class) : Vector(U) forall U
|
||||||
els = @elements.map { |e| klass.new(e).as(U) }
|
els = @elements.map { |e| klass.new(e).as(U) }
|
||||||
Vector.elements(els)
|
self.class.elements(els)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the elements of the vector in an array.
|
# Returns the elements of the vector in an array.
|
||||||
|
|
Loading…
Reference in New Issue