Module: Amalgalite::SQLite3::Constants::Helpers

Included in:
Config, DBStatus, DataType, Open, ResultCode, StatementStatus, Status
Defined in:
lib/amalgalite/sqlite3/constants.rb

Instance Method Summary collapse

Instance Method Details

#name_from_value(value) ⇒ Object

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



12
13
14
15
16
17
18
19
20
21
# 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) ⇒ Object

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



27
28
29
30
31
32
33
34
35
36
# 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