lib/eve/javascript_helper.rb
def type_id(which)
      which = which.to_s.humanize unless which.kind_of?(String)
      which.downcase!
      case which
        when 'alliance' then 16159
        when 'character' then 1377
        when 'corporation' then 2
        when 'constellation' then 4
        when 'region' then 3
        when 'solar system', 'solarsystem' then 5
        when 'station' then 3867
        else raise ArgumentError, "Unknown type: #{which}"
      end
    end
def type_id(which)
      which = which.to_s.humanize unless which.kind_of?(String)
      which.downcase!
      case which
        when 'alliance' then 16159
        when 'character' then 1377
        when 'corporation' then 2
        when 'constellation' then 4
        when 'region' then 3
        when 'solar system', 'solarsystem' then 5
        when 'station' then 3867
        else raise ArgumentError, "Unknown type: #{which}"
      end
    end
Returns the numeric type ID for a string, so you don't have to manage "magic numbers" in your application.
 The argument can be a string or a symbol, and is case insensitive. Underscores will be converted to spaces.

 Examples:
   type_id('alliance')       # => 16159
   type_id('character')      # => 1377
   type_id('corporation')    # => 2
   type_id('constellation')  # => 4
   type_id('region')         # => 3
   type_id('Solar System')   # => 5
   type_id(:solar_system)    # => 5
   type_id(:station)         # => 3867