1
0
Fork 0
mirror of https://github.com/awesome-print/awesome_print synced 2023-03-27 23:22:34 -04:00

Create AwesomePrint::FormatterFactory.from

This commit is contained in:
Mauro George 2015-03-19 18:20:59 -03:00
parent a4d960f1c8
commit 1dd896fcee
2 changed files with 5 additions and 1 deletions

View file

@ -19,7 +19,7 @@ module AwesomePrint
def format(object) def format(object)
@type = printable(object) @type = printable(object)
@object = object @object = object
AwesomePrint::FormatterFactory.new(self, object).call AwesomePrint::FormatterFactory.from(self, object)
end end
# Pick the color and apply it to the given string as necessary. # Pick the color and apply it to the given string as necessary.

View file

@ -3,6 +3,10 @@ require 'awesome_print/formatters'
module AwesomePrint module AwesomePrint
class FormatterFactory class FormatterFactory
def self.from(formatter, object)
new(formatter, object).call
end
def initialize(formatter, object) def initialize(formatter, object)
@type = AwesomePrint::TypeDiscover.new(formatter).call @type = AwesomePrint::TypeDiscover.new(formatter).call
@class_name = @type.to_s.split('_').map(&:capitalize).join('') @class_name = @type.to_s.split('_').map(&:capitalize).join('')