Class: StreamStats::Counter
- Inherits:
-
Object
- Object
- StreamStats::Counter
- Defined in:
- lib/stream_stats/counter.rb,
ext/stream_stats/stream_stats_counter.c
Instance Method Summary collapse
- #<<(rb_sample) ⇒ Object
- #count ⇒ Object
- #initialize ⇒ Object constructor
- #inspect ⇒ Object
- #max ⇒ Object
- #mean ⇒ Object
- #min ⇒ Object
- #squared_sum ⇒ Object
- #stddev ⇒ Object
- #sum ⇒ Object
Constructor Details
#initialize ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'ext/stream_stats/stream_stats_counter.c', line 8
static VALUE strstat_counter_init(VALUE self) {
counter *i_counter = (counter *) malloc(sizeof(counter));
init_counter(i_counter);
VALUE data = Data_Wrap_Struct(counter_class, NULL, free, i_counter);
rb_ivar_set(self, rb_intern("internal_struct"), data);
return Qnil;
}
|
Instance Method Details
#<<(rb_sample) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'ext/stream_stats/stream_stats_counter.c', line 28
static VALUE strstat_counter_add_sample(VALUE self, VALUE rb_sample) {
double sample = NUM2DBL(rb_sample);
counter *i_counter = (counter*) strstat_get_struct(self);
int returned = counter_add_sample(i_counter, sample);
if (returned != 0) {
rb_raise(rb_eRuntimeError, "add sample returned %d", returned);
}
return Qnil;
}
|
#count ⇒ Object
42 43 44 45 46 |
# File 'ext/stream_stats/stream_stats_counter.c', line 42
static VALUE strstat_counter_count(VALUE self) {
counter *i_counter = (counter*) strstat_get_struct(self);
return LONG2NUM(counter_count(i_counter));
}
|
#inspect ⇒ Object
4 5 6 7 8 9 |
# File 'lib/stream_stats/counter.rb', line 4 def inspect attr_list = [:count, :sum, :min, :max, :mean, :stddev].map do |method| "#{method.to_s}: #{self.send(method)}" end * ', ' "#{self.to_s} {#{attr_list}}" end |
#max ⇒ Object
56 57 58 |
# File 'ext/stream_stats/stream_stats_counter.c', line 56 static VALUE strstat_counter_max(VALUE self) { return strstat_counter_commoncall(self, counter_max); } |
#mean ⇒ Object
59 60 61 |
# File 'ext/stream_stats/stream_stats_counter.c', line 59 static VALUE strstat_counter_mean(VALUE self) { return strstat_counter_commoncall(self, counter_mean); } |
#min ⇒ Object
53 54 55 |
# File 'ext/stream_stats/stream_stats_counter.c', line 53 static VALUE strstat_counter_min(VALUE self) { return strstat_counter_commoncall(self, counter_min); } |
#squared_sum ⇒ Object
68 69 70 |
# File 'ext/stream_stats/stream_stats_counter.c', line 68 static VALUE strstat_counter_squared_sum(VALUE self) { return strstat_counter_commoncall(self, counter_squared_sum); } |
#stddev ⇒ Object
62 63 64 |
# File 'ext/stream_stats/stream_stats_counter.c', line 62 static VALUE strstat_counter_stddev(VALUE self) { return strstat_counter_commoncall(self, counter_stddev); } |
#sum ⇒ Object
65 66 67 |
# File 'ext/stream_stats/stream_stats_counter.c', line 65 static VALUE strstat_counter_sum(VALUE self) { return strstat_counter_commoncall(self, counter_sum); } |