Class: Range
- Inherits:
-
Object
- Object
- Range
- Defined in:
- lib/carray/basics.rb
Overview
Reopened to add #to_ca, so a Range can be handed to any CArray entry
point that coerces its operand (CArray.cast, wrap_readonly, meshgrid).
Instance Method Summary collapse
-
#to_ca(writable: false) ⇒ CArray
Returns the members of
selfas a 1-DCA_OBJECTCArray.
Instance Method Details
#to_ca(writable: false) ⇒ CArray
435 436 437 438 439 440 441 442 443 444 445 |
# File 'lib/carray/basics.rb', line 435 def to_ca(writable: false) if writable raise "#{self.class}#to_ca builds a new array; " \ "it can't satisfy `writable: true'" end first, last = self.begin, self.end if first.is_a?(Integer) and last.is_a?(Integer) and first > last return CA_OBJECT(self, 1) # step 1: signed arange end return CA_OBJECT(self) end |