Class: Numo::NArray::Step
- Inherits:
-
Object
- Object
- Numo::NArray::Step
- Includes:
- Enumerable
- Defined in:
- ext/numo/narray/step.c
Instance Method Summary collapse
-
#begin ⇒ Object
Returns the start of step.
-
#end ⇒ Object
Returns the object that defines the end of step.
-
#exclude_end? ⇒ Boolean
Returns
true
if step excludes its end value. -
#first ⇒ Object
Returns the start of step.
-
#initialize(*args) ⇒ Object
constructor
Constructs a step using three parameters among start, end, step and length.
-
#last ⇒ Object
Returns the object that defines the end of step.
-
#length ⇒ Object
Returns the length of step.
-
#size ⇒ Object
Returns the length of step.
-
#step ⇒ Object
Returns the step of step.
Constructor Details
#new(start, end) ⇒ Object #new(range, step = nil, length = nil) ⇒ Object
Constructs a step using three parameters among start, end, step and length. start, end parameters can be replaced with range. If the step is omitted (or supplied with nil), then calculated from length or definded as 1.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'ext/numo/narray/step.c', line 107
static VALUE
step_initialize( int argc, VALUE *argv, VALUE self )
{
VALUE a, b=Qnil, c=Qnil, d=Qnil, e=Qnil;
rb_scan_args(argc, argv, "13", &a, &b, &c, &d);
/* Selfs are immutable, so that they should be initialized only once. */
if (rb_ivar_defined(self, id_beg)) {
rb_name_error(rb_intern("initialize"), "`initialize' called twice");
}
if (rb_obj_is_kind_of(a,rb_cRange)) {
if (argc>3) {
rb_raise(rb_eArgError, "extra argument");
}
d = c;
c = b;
e = rb_funcall(a, rb_intern("exclude_end?"), 0);
//b = rb_ivar_get(a, id_end);
b = rb_funcall(a, id_end, 0);
//a = rb_ivar_get(a, id_beg);
a = rb_funcall(a, id_beg, 0);
}
step_init(self, a, b, c, d, e);
return Qnil;
}
|
Instance Method Details
#begin ⇒ Object #first ⇒ Object
Returns the start of step.
141 142 143 144 145 |
# File 'ext/numo/narray/step.c', line 141
static VALUE
step_first( VALUE self )
{
return rb_ivar_get(self, id_beg);
}
|
#end ⇒ Object #last ⇒ Object
Returns the object that defines the end of step.
155 156 157 158 159 |
# File 'ext/numo/narray/step.c', line 155
static VALUE
step_last( VALUE self )
{
return rb_ivar_get(self, id_end);
}
|
#exclude_end? ⇒ Boolean
Returns true
if step excludes its end value.
194 195 196 197 198 |
# File 'ext/numo/narray/step.c', line 194
static VALUE
step_exclude_end_p(VALUE self)
{
return RTEST(rb_ivar_get(self, id_excl)) ? Qtrue : Qfalse;
}
|
#begin ⇒ Object #first ⇒ Object
Returns the start of step.
141 142 143 144 145 |
# File 'ext/numo/narray/step.c', line 141
static VALUE
step_first( VALUE self )
{
return rb_ivar_get(self, id_beg);
}
|
#end ⇒ Object #last ⇒ Object
Returns the object that defines the end of step.
155 156 157 158 159 |
# File 'ext/numo/narray/step.c', line 155
static VALUE
step_last( VALUE self )
{
return rb_ivar_get(self, id_end);
}
|
#length ⇒ Object #size ⇒ Object
Returns the length of step.
169 170 171 172 173 |
# File 'ext/numo/narray/step.c', line 169
static VALUE
step_length( VALUE self )
{
return rb_ivar_get(self, id_len);
}
|
#length ⇒ Object #size ⇒ Object
Returns the length of step.
169 170 171 172 173 |
# File 'ext/numo/narray/step.c', line 169
static VALUE
step_length( VALUE self )
{
return rb_ivar_get(self, id_len);
}
|
#step ⇒ Object
Returns the step of step.
182 183 184 185 186 |
# File 'ext/numo/narray/step.c', line 182
static VALUE
step_step( VALUE self )
{
return rb_ivar_get(self, id_step);
}
|