Sha256: f05657740687a48ed68cc1fb566413745d9520e0d8175e0603148b3829929fef

Contents?: true

Size: 934 Bytes

Versions: 23

Compression:

Stored size: 934 Bytes

Contents

class Chouette::AccessPointType < ActiveSupport::StringInquirer

  def initialize(text_code, numerical_code)
    super text_code.to_s
    @numerical_code = numerical_code
  end

  def self.new(text_code, numerical_code = nil)
    if text_code and numerical_code
      super
    elsif self === text_code 
      text_code
    else
      if Fixnum === text_code
        text_code, numerical_code = definitions.rassoc(text_code)
      else
        text_code, numerical_code = definitions.assoc(text_code.to_s)
      end

      super text_code, numerical_code
    end
  end

  def to_i
    @numerical_code
  end

  def inspect
    "#{to_s}/#{to_i}"
  end

  def name
    camelize
  end

  @@definitions = [
    ["in", 0],
    ["out", 1],
    ["in_out", 2]
  ]
  cattr_reader :definitions

  @@all = nil
  def self.all
    @@all ||= definitions.collect do |text_code, numerical_code|
      new(text_code, numerical_code)
    end
  end

end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
ninoxe-1.2.3 app/models/chouette/access_point_type.rb
ninoxe-1.2.2 app/models/chouette/access_point_type.rb
ninoxe-1.2.1 app/models/chouette/access_point_type.rb
ninoxe-1.2.0 app/models/chouette/access_point_type.rb
ninoxe-1.1.5 app/models/chouette/access_point_type.rb
ninoxe-1.1.4 app/models/chouette/access_point_type.rb
ninoxe-1.1.3 app/models/chouette/access_point_type.rb
ninoxe-1.1.2 app/models/chouette/access_point_type.rb
ninoxe-1.1.1 app/models/chouette/access_point_type.rb
ninoxe-1.1.0 app/models/chouette/access_point_type.rb
ninoxe-1.0.3 app/models/chouette/access_point_type.rb
ninoxe-1.0.2 app/models/chouette/access_point_type.rb
ninoxe-1.0.1 app/models/chouette/access_point_type.rb
ninoxe-1.0.0 app/models/chouette/access_point_type.rb
ninoxe-0.1.6 app/models/chouette/access_point_type.rb
ninoxe-0.1.5 app/models/chouette/access_point_type.rb
ninoxe-0.1.4 app/models/chouette/access_point_type.rb
ninoxe-0.1.3 app/models/chouette/access_point_type.rb
ninoxe-0.1.2 app/models/chouette/access_point_type.rb
ninoxe-0.1.1 app/models/chouette/access_point_type.rb