コンストラクタを分割したメソッドを持つクラスのことを「Builder」
Builderクラスのメソッドを生成手順に沿って呼び出すクラスを「Director」
class Human
attr_accessor :race, :country
end
class HumanBuilder
def initialize
@human = Human.new
end
def add_rage(race)
@human.race = race
end
def add_country(country)
@human.country = country
end
def instance
@human
end
end
class JapaneseDirector
def self.create(builder)
builder.add_race('asian')
builder.add_country('japan')
builder.instance
end
end
builder = HumanBuilder.new
japanese = JapaneseDirector.create(builder)