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
trueif 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.
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'ext/numo/narray/step.c', line 112
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.
146 147 148 149 150 |
# File 'ext/numo/narray/step.c', line 146
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.
160 161 162 163 164 |
# File 'ext/numo/narray/step.c', line 160
static VALUE
step_last( VALUE self )
{
return rb_ivar_get(self, id_end);
}
|
#exclude_end? ⇒ Boolean
Returns true if step excludes its end value.
199 200 201 202 203 |
# File 'ext/numo/narray/step.c', line 199
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.
146 147 148 149 150 |
# File 'ext/numo/narray/step.c', line 146
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.
160 161 162 163 164 |
# File 'ext/numo/narray/step.c', line 160
static VALUE
step_last( VALUE self )
{
return rb_ivar_get(self, id_end);
}
|
#length ⇒ Object #size ⇒ Object
Returns the length of step.
174 175 176 177 178 |
# File 'ext/numo/narray/step.c', line 174
static VALUE
step_length( VALUE self )
{
return rb_ivar_get(self, id_len);
}
|
#length ⇒ Object #size ⇒ Object
Returns the length of step.
174 175 176 177 178 |
# File 'ext/numo/narray/step.c', line 174
static VALUE
step_length( VALUE self )
{
return rb_ivar_get(self, id_len);
}
|
#step ⇒ Object
Returns the step of step.
187 188 189 190 191 |
# File 'ext/numo/narray/step.c', line 187
static VALUE
step_step( VALUE self )
{
return rb_ivar_get(self, id_step);
}
|