120), Grade.new(:B, 100) ].each_with_object({}){|g,h| h[g.sym] = g }.freeze class Person attr_reader :name, :grade def initialize(name:, grade:) @name, @grade = name, GRADES[grade] end end class Review class Excellent < Review def call(base) base + 50 end end class Standard < Review def call(base) base end end class Poor < Review def call(base) base * 0.8 end end def self.of(sym) @_types ||= { excellent: Excellent.new, standard: Standard.new, poor: Poor.new } @_types[sym] end def call(base); end end class Bonus attr_reader :person, :review def initialize(person, review:) @person, @review = person, Review.of(review) end # Ϙʔφε: άϨʔυ͝ͱͷϕʔεֹۚΛධՁʹΑͬͯ૿ݮֹͤͨۚ͞ def call @person.grade.base.then {|b| @review.call(b)} end end QFSTPOͷάϨʔυ͝ͱͷج४ֹۚΛɺ ϨϏϡʔ݁Ռʹͯ͠ɺϘʔφεΛࢉग़͠ ͍ͯΔ UFMM #POVTάϨʔυͱϨϏϡʔʹ ࣄΛ͓ئ͍͍ͯ͠Δ UFMM