Module: CMSScanner::Formatter::ClassMethods
- Included in:
- CMSScanner::Formatter
- Defined in:
- lib/cms_scanner/formatter.rb
Overview
Module to be able to do Formatter.load() & Formatter.availables and do that as well when the Formatter is included in another module
Instance Method Summary collapse
-
#availables ⇒ Array<String>
@note: the #load method above should then be used to create the associated formatter.
- #load(format = nil, custom_views = nil) ⇒ Formatter::Base
Instance Method Details
#availables ⇒ Array<String>
@note: the #load method above should then be used to create the associated formatter
26 27 28 29 30 31 32 33 |
# File 'lib/cms_scanner/formatter.rb', line 26 def availables formatters = NS::Formatter.constants.select do |const| name = NS::Formatter.const_get(const) name.is_a?(Class) && name != NS::Formatter::Base end formatters.map { |sym| sym.to_s.underscore.dasherize } end |
#load(format = nil, custom_views = nil) ⇒ Formatter::Base
15 16 17 18 19 20 21 22 |
# File 'lib/cms_scanner/formatter.rb', line 15 def load(format = nil, custom_views = nil) format ||= 'cli' custom_views ||= [] f = const_get(format.tr('-', '_').camelize).new custom_views.each { |v| f.views_directories << v } f end |