Class: Counter

Inherits:
Object
  • Object
show all
Defined in:
ext/stats/stats-ruby.c

Instance Method Summary collapse

Instance Method Details

#add(amt) ⇒ Object



472
473
474
475
476
477
478
479
480
481
# File 'ext/stats/stats-ruby.c', line 472

VALUE rbctr_add(VALUE self, VALUE amt)
{
    struct stats_counter *counter = NULL;

    Check_Type(amt,T_FIXNUM);

    Data_Get_Struct(self, struct stats_counter, counter);
    counter_increment_by(counter,FIX2LONG(amt));
    return self;
}

#clrObject



483
484
485
486
487
488
489
490
# File 'ext/stats/stats-ruby.c', line 483

VALUE rbctr_clr(VALUE self)
{
    struct stats_counter *counter = NULL;

    Data_Get_Struct(self, struct stats_counter, counter);
    counter_clear(counter);
    return self;
}

#getObject



492
493
494
495
496
497
498
499
500
# File 'ext/stats/stats-ruby.c', line 492

VALUE rbctr_get(VALUE self)
{
    struct stats_counter *counter = NULL;
    long long val;

    Data_Get_Struct(self, struct stats_counter, counter);
    val = counter_get_value(counter);
    return LONG2FIX(val);
}

#incObject



463
464
465
466
467
468
469
470
# File 'ext/stats/stats-ruby.c', line 463

VALUE rbctr_inc(VALUE self)
{
    struct stats_counter *counter = NULL;

    Data_Get_Struct(self, struct stats_counter, counter);
    counter_increment(counter);
    return self;
}

#set(amt) ⇒ Object



502
503
504
505
506
507
508
509
510
511
# File 'ext/stats/stats-ruby.c', line 502

VALUE rbctr_set(VALUE self, VALUE amt)
{
    struct stats_counter *counter = NULL;

    Check_Type(amt,T_FIXNUM);

    Data_Get_Struct(self, struct stats_counter, counter);
    counter_set(counter,FIX2LONG(amt));
    return self;
}