Sha256: ccc45f8904de1239e50d4076af4abb6ac5509565d9cfaba4e1b59a0038837512

Contents?: true

Size: 784 Bytes

Versions: 1

Compression:

Stored size: 784 Bytes

Contents

module TokyoMetro::Modules::Db::Model

  include ::TokyoMetro::Modules::Common::ConvertConstantToClassMethod

  GROUP = ::YAML.load_file( "#{ ::TokyoMetro.dictionary_dir }/models.yaml" )

  def self.list
    make_list( group )
  end

  def self.list_sort_by_alphabet
    make_list( { "All" => group.values.flatten.sort } )
  end

  class << self

    private

    def make_list(h)
      model_ary = ::Array.new
      h.each do | category , models |
        models.each.with_index(1) do | model , i |
          if i == 1
            category_name = category
          else
            category_name = nil
          end

          model_ary << { category: category_name , model: model , count: eval( "::#{ model }.all.count" ) }
        end
      end
      model_ary
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tokyo_metro-0.10.1 lib/tokyo_metro/modules/db/model.rb