class TokyoMetro::Factory::Generate::Static::MetaClass::Group::MultipleYamls

各種ハッシュを作成するための Factory クラス - 2.1 複数の YAML ファイルからハッシュを作成 @note

{TokyoMetro::Static::TrainType::Custom::Main} ,{ TokyoMetro::Static::Operator} で使用する。

Public Class Methods

new( files ) click to toggle source

Constructor

# File lib/tokyo_metro/factory/generate/static/meta_class/group/multiple_yamls.rb, line 7
def initialize( files )
  @files = files
end

Private Class Methods

from_yamls( files = nil ) click to toggle source

@note ロジックは {TokyoMetro::Factory::Generate::Static::MetaClass::Group::Fundamental::FromHash.from_yamls} とほとんど同じだが、デフォルトのファイルがリスト(配列)であることに注意

# File lib/tokyo_metro/factory/generate/static/meta_class/group/multiple_yamls.rb, line 44
def self.from_yamls( files = nil )
  if files.nil?
    files = yaml_files
  end
  self.new( files ).generate
end

Public Instance Methods

generate() click to toggle source

YAML ファイルからインスタンスを生成するためのインスタンスメソッド @return [subclass of Hash]

# File lib/tokyo_metro/factory/generate/static/meta_class/group/multiple_yamls.rb, line 13
def generate
  if TO_INSPECT
    inspect_title
  end

  h_new = self.class.hash_class_for_this_factory.new
  h_new = generating_procedure( h_new )
  h_new
end
inspect_title() click to toggle source
# File lib/tokyo_metro/factory/generate/static/meta_class/group/multiple_yamls.rb, line 23
def inspect_title
  puts "● #{self.class.name}"
  puts " " * 4 + "< TokyoMetro::Factory::Generate::Static::MetaClass::Group::MultipleYamls"
  puts ""
end

Private Instance Methods

generating_procedure( h_new ) click to toggle source

YAML ファイルからインスタンスを生成する際のロジック @return [Proc]

# File lib/tokyo_metro/factory/generate/static/meta_class/group/multiple_yamls.rb, line 35
def generating_procedure( h_new )
  @files.each do | file |
    hash_sub = self.class.factory_for_generating_from_each_saved_file.from_yaml( file )
    h_new = h_new.merge( hash_sub )
  end
  h_new
end