class TokyoMetro::Factory::Save::Api::MetaClass::Group::List

グループ化されたデータの配列

Public Class Methods

factory_for_saving_to_each_file() click to toggle source

保存の際に使用する Factory Pattern クラス

# File lib/tokyo_metro/factory/save/api/meta_class/group/list.rb, line 34
def self.factory_for_saving_to_each_file
  raise "Error: The class method \'#{__method__}\' is not defined yet in this class \'#{ self.name }\'."
end

Public Instance Methods

save_datas( db_dir , file_type , instance_is_generated = false ) click to toggle source

配列内の各データを保存するメソッド @param db_dir [String (dirname) or Const (Class)] 「データベースのディレクトリを示す文字列」または「クラスを表す定数」 @param file_type [Symbol or nil] 保存するファイルの種類 @note

db_dir を定義しない場合は、このモジュールが組み込まれたクラスのクラスメソッド db_dirname を呼び出す。
また、クラスを表す定数が指定された場合は、指定されたクラスのクラスメソッド db_dirname が呼び出される。

@return [nil]

# File lib/tokyo_metro/factory/save/api/meta_class/group/list.rb, line 11
def save_datas( db_dir , file_type , instance_is_generated = false )
  unless self.empty?
    puts "○ #{self.length} files will be generated."
    save_datas__check_varidity

    factory = self.class.factory_for_saving_to_each_file

    _digit_of_length = digit_of_length
    print_header( _digit_of_length )
    self.each.with_index(1) do | fileinfo , i |
      factory.process( fileinfo.list , fileinfo.filename , db_dir , nil , file_type )
      print_inspect_info( i , _digit_of_length )
    end
  else
    puts "○ No file will be generated."
  end

  puts "\n" * 2

  return nil
end

Private Instance Methods

digit_of_length() click to toggle source
# File lib/tokyo_metro/factory/save/api/meta_class/group/list.rb, line 61
def digit_of_length
  raise "Error" unless division % 10 == 0
  ( self.length + division ).to_s.length
end
division() click to toggle source
# File lib/tokyo_metro/factory/save/api/meta_class/group/list.rb, line 66
def division
  if self.length >= 10000
    100 * rate
  else
    100
  end
end
print_header( _digit_of_length ) click to toggle source
print_inspect_info( i , _digit_of_length ) click to toggle source
rate() click to toggle source
# File lib/tokyo_metro/factory/save/api/meta_class/group/list.rb, line 74
def rate
  20
end
save_datas__check_varidity() click to toggle source
# File lib/tokyo_metro/factory/save/api/meta_class/group/list.rb, line 45
def save_datas__check_varidity
  unless self.all? { |i| i.instance_of?( self.class.file_info_class_for_saving ) }
    raise "Error"
  end
end