module Amalgalite::SQLite3::Constants::Helpers

Public Instance Methods

name_from_value( value ) click to toggle source

convert an integer value into the string representation of the associated constant. this is a helper method used by some of the other modules

# File lib/amalgalite/sqlite3/constants.rb, line 12
def name_from_value( value )
  unless defined? @const_map_from_value
    @const_map_from_value = {}
    constants.each do |const_name|
      c_int = const_get( const_name )
      @const_map_from_value[c_int] = const_name.to_s
    end
  end
  return @const_map_from_value[ value ]
end
value_from_name( name ) click to toggle source

convert a string into the constant value. This is helper method used by some of the other modules

# File lib/amalgalite/sqlite3/constants.rb, line 27
def value_from_name( name )
  unless defined? @const_map_from_name
    @const_map_from_name = {}
    constants.each do |const_name|
      c_int = const_get( const_name )
      @const_map_from_name[ const_name.to_s ] = c_int
    end
  end
  return @const_map_from_name[ name.upcase ]
end