Class: Informix::Slob::Stat
- Inherits:
-
Object
- Object
- Informix::Slob::Stat
- Includes:
- Comparable
- Defined in:
- ext/informixc.c
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
stat <=> other_stat => -1, 0, 1.
-
#atime ⇒ Object
stat.atime => time.
-
#ctime ⇒ Object
stat.ctime => time.
-
#initialize(slob) ⇒ Object
constructor
Slob::Stat.new(slob) => stat.
-
#mtime ⇒ Object
stat.mtime => time.
-
#refcnt ⇒ Object
stat.refcnt => fixnum.
-
#size ⇒ Object
stat.size => fixnum or bignum.
Constructor Details
#initialize(slob) ⇒ Object
Slob::Stat.new(slob) => stat
Creates an Slob::Stat object with status information for the given Slob object.
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 |
# File 'ext/informixc.c', line 331 static VALUE rb_slobstat_initialize(VALUE self, VALUE slob) { mint ret; slob_t *sb; slobstat_t *stat; ifx_lo_stat_t *st; /* * EXEC SQL begin declare section; */ #line 284 "informixc.ec" #line 285 "informixc.ec" char *did; /* * EXEC SQL end declare section; */ #line 286 "informixc.ec" Data_Get_Struct(slob, slob_t, sb); Data_Get_Struct(self, slobstat_t, stat); if (sb->fd == -1) rb_raise(rb_eProgrammingError, "Open the Slob object before getting its status"); did = sb->database_id; /* * EXEC SQL set connection :did; */ #line 296 "informixc.ec" { #line 296 "informixc.ec" sqli_connect_set(0, did, 0); #line 296 "informixc.ec" } if (SQLCODE < 0) raise_ifx_extended(); ret = ifx_lo_stat(sb->fd, &st); if (ret < 0) raise_ifx_extended(); stat->atime = ifx_lo_stat_atime(st); stat->ctime = ifx_lo_stat_ctime(st); stat->mtime = ifx_lo_stat_mtime_sec(st); stat->refcnt = ifx_lo_stat_refcnt(st); ret = ifx_lo_stat_size(st, &stat->size); ifx_lo_stat_free(st); if (stat->atime == -1 || stat->ctime == -1 || stat->mtime == -1 || stat->refcnt == -1 || ret == -1) { rb_raise(rb_eOperationalError, "Unable to get status"); } return self; } |
Instance Method Details
#<=>(other) ⇒ Object
stat <=> other_stat => -1, 0, 1
Compares with another Slob::Stat
object by comparing their modification times.
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 |
# File 'ext/informixc.c', line 398 static VALUE rb_slobstat_cmp(VALUE self, VALUE other) { if (rb_obj_is_kind_of(other, rb_obj_class(self))) { slobstat_t *stat; time_t t1, t2; Data_Get_Struct(self, slobstat_t, stat); t1 = stat->mtime; Data_Get_Struct(other, slobstat_t, stat); t2 = stat->mtime; if (t1 == t2) return INT2FIX(0); else if (t1 < t2) return INT2FIX(-1); else return INT2FIX(1); } return Qnil; } |
#atime ⇒ Object
stat.atime => time
Returns the time of last access as a Time object.
425 426 427 428 429 430 431 432 |
# File 'ext/informixc.c', line 425 static VALUE rb_slobstat_atime(VALUE self) { slobstat_t *stat; Data_Get_Struct(self, slobstat_t, stat); return rb_time_new(stat->atime, 0); } |
#ctime ⇒ Object
stat.ctime => time
Returns the time of last change in status as a Time object.
440 441 442 443 444 445 446 447 |
# File 'ext/informixc.c', line 440 static VALUE rb_slobstat_ctime(VALUE self) { slobstat_t *stat; Data_Get_Struct(self, slobstat_t, stat); return rb_time_new(stat->ctime, 0); } |
#mtime ⇒ Object
stat.mtime => time
Returns the time of last modification as a Time object.
455 456 457 458 459 460 461 462 |
# File 'ext/informixc.c', line 455 static VALUE rb_slobstat_mtime(VALUE self) { slobstat_t *stat; Data_Get_Struct(self, slobstat_t, stat); return rb_time_new(stat->mtime, 0); } |
#refcnt ⇒ Object
stat.refcnt => fixnum
Returns the number of references
470 471 472 473 474 475 476 477 |
# File 'ext/informixc.c', line 470 static VALUE rb_slobstat_refcnt(VALUE self) { slobstat_t *stat; Data_Get_Struct(self, slobstat_t, stat); return INT2FIX(stat->refcnt); } |
#size ⇒ Object
stat.size => fixnum or bignum
Returns the size in bytes
485 486 487 488 489 490 491 492 493 494 495 |
# File 'ext/informixc.c', line 485 static VALUE rb_slobstat_size(VALUE self) { slobstat_t *stat; VALUE size; Data_Get_Struct(self, slobstat_t, stat); INT82NUM(&stat->size, size); return size; } |