class Amalgalite::SQLite3::Stat
class encapsulating a single Stat
A Stat represents a single Status code and its current highwater mark.
Some stats may not have a current or a highwater value, in those cases the
associated has_current? or has_highwater? method returns
false and the current or highwater method also returns
nil
.
Attributes
code[R]
name[R]
Public Class Methods
new( name )
click to toggle source
# File lib/amalgalite/sqlite3/status.rb, line 15 def initialize( name ) @name = name @code = ::Amalgalite::SQLite3::Constants::Status.value_from_name( name ) @current = nil @highwater = nil end
Public Instance Methods
current()
click to toggle source
# File lib/amalgalite/sqlite3/status.rb, line 22 def current update! return @current end
highwater()
click to toggle source
# File lib/amalgalite/sqlite3/status.rb, line 27 def highwater update! return @highwater end
reset!()
click to toggle source
reset the given stat's highwater mark. This will also populate the _@current_ and _@highwater_ instance variables
# File lib/amalgalite/sqlite3/status.rb, line 36 def reset! update!( true ) end
Amalgalite::SQLite3::Stat.update!( reset = false ) → nil
click to toggle source
Populates the _@current_ and _@higwater_ instance variables of self object with the values from the sqlite3_status call. If reset it true then the highwater mark for the stat is reset
VALUE am_sqlite3_stat_update_bang( int argc, VALUE *argv, VALUE self ) { int status_op = -1; int current = -1; int highwater = -1; VALUE reset = Qfalse; int reset_flag = 0; int rc; status_op = FIX2INT( rb_iv_get( self, "@code" ) ); if ( argc > 0 ) { reset = argv[0]; reset_flag = ( Qtrue == reset ) ? 1 : 0 ; } rc = sqlite3_status( status_op, ¤t, &highwater, reset_flag ); if ( SQLITE_OK != rc ) { VALUE n = rb_iv_get( self, "@name" ) ; char* name = StringValuePtr( n ); rb_raise(eAS_Error, "Failure to retrieve status for %s : [SQLITE_ERROR %d] \n", name, rc); } rb_iv_set( self, "@current", INT2NUM( current ) ); rb_iv_set( self, "@highwater", INT2NUM( highwater) ); return Qnil; }