Sha256: d118a88d98b59cf966a6037ae86c2cc6d392230b553eaaaf9b9b1a52acce51f2
Contents?: true
Size: 729 Bytes
Versions: 2
Compression:
Stored size: 729 Bytes
Contents
module Pronto module Formatter class << self def register(formatter_klass) unless formatter_klass.method_defined?(:format) raise NoMethodError, "format method is not declared in the #{formatter_klass.name} class." end base = Pronto::Formatter::Base raise "#{formatter_klass.name} is not a #{base}" unless formatter_klass.ancestors.include?(base) @formatters ||= {} @formatters[formatter_klass.name] = formatter_klass end def get(names) names ||= 'text' Array(names).map { |name| @formatters[name.to_s] || TextFormatter } .uniq.map(&:new) end def names @formatters.keys end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pronto-0.11.3 | lib/pronto/formatter/formatter.rb |
pronto-0.11.2 | lib/pronto/formatter/formatter.rb |