Class: OracleDB::IntervalDS
- Inherits:
-
Object
- Object
- OracleDB::IntervalDS
- Defined in:
- lib/oracledb.rb,
ext/oracledb/rboradb_datetime.c
Instance Method Summary collapse
- #days ⇒ Object
- #fseconds ⇒ Object
- #hours ⇒ Object
- #initialize(*args) ⇒ Object constructor
- #inspect ⇒ Object
- #minutes ⇒ Object
- #seconds ⇒ Object
- #to_a ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(*args) ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'ext/oracledb/rboradb_datetime.c', line 153
static VALUE interval_ds_initialize(int argc, VALUE *argv, VALUE self)
{
dpiIntervalDS *val = To_IntervalDS(self);
VALUE days, hours, minutes, seconds, fseconds;
rb_scan_args(argc, argv, "05", &days, &hours, &minutes, &seconds, &fseconds);
val->days = NIL_P(days) ? 0 : NUM2INT(days);
val->hours = NIL_P(hours) ? 0 : NUM2INT(hours);
val->minutes = NIL_P(minutes) ? 0 : NUM2INT(minutes);
val->seconds = NIL_P(seconds) ? 0 : NUM2INT(seconds);
val->fseconds = NIL_P(fseconds) ? 0 : NUM2INT(fseconds);
return Qnil;
}
|
Instance Method Details
#days ⇒ Object
187 188 189 190 191 |
# File 'ext/oracledb/rboradb_datetime.c', line 187
static VALUE interval_ds_days(VALUE self)
{
dpiIntervalDS *val = To_IntervalDS(self);
return INT2NUM(val->days);
}
|
#fseconds ⇒ Object
211 212 213 214 215 |
# File 'ext/oracledb/rboradb_datetime.c', line 211
static VALUE interval_ds_fseconds(VALUE self)
{
dpiIntervalDS *val = To_IntervalDS(self);
return INT2NUM(val->fseconds);
}
|
#hours ⇒ Object
193 194 195 196 197 |
# File 'ext/oracledb/rboradb_datetime.c', line 193
static VALUE interval_ds_hours(VALUE self)
{
dpiIntervalDS *val = To_IntervalDS(self);
return INT2NUM(val->hours);
}
|
#inspect ⇒ Object
179 180 181 182 183 |
# File 'lib/oracledb.rb', line 179 def inspect "#<#{self.class}:#{self.to_s}>" rescue "#<#{self.class}:ERROR: #{$!.}>" end |
#minutes ⇒ Object
199 200 201 202 203 |
# File 'ext/oracledb/rboradb_datetime.c', line 199
static VALUE interval_ds_minutes(VALUE self)
{
dpiIntervalDS *val = To_IntervalDS(self);
return INT2NUM(val->minutes);
}
|
#seconds ⇒ Object
205 206 207 208 209 |
# File 'ext/oracledb/rboradb_datetime.c', line 205
static VALUE interval_ds_seconds(VALUE self)
{
dpiIntervalDS *val = To_IntervalDS(self);
return INT2NUM(val->seconds);
}
|
#to_a ⇒ Object
167 168 169 170 171 172 173 174 175 176 177 |
# File 'ext/oracledb/rboradb_datetime.c', line 167
static VALUE interval_ds_to_a(VALUE self)
{
dpiIntervalDS *val = To_IntervalDS(self);
VALUE ary = rb_ary_new_capa(5);
rb_ary_push(ary, INT2NUM(val->days));
rb_ary_push(ary, INT2NUM(val->hours));
rb_ary_push(ary, INT2NUM(val->minutes));
rb_ary_push(ary, INT2NUM(val->seconds));
rb_ary_push(ary, INT2NUM(val->fseconds));
return ary;
}
|
#to_s ⇒ Object
179 180 181 182 183 184 185 |
# File 'ext/oracledb/rboradb_datetime.c', line 179
static VALUE interval_ds_to_s(VALUE self)
{
dpiIntervalDS *val = To_IntervalDS(self);
char sign = (val->days >= 0 && val->hours >= 0 && val->minutes >= 0 && val->seconds >= 0 && val->fseconds >= 0) ? '+' : '-';
return rb_sprintf("%c%0d %02d:%02d:%02d.%09d",
sign, abs(val->days), abs(val->hours), abs(val->minutes), abs(val->seconds), abs(val->fseconds));
}
|