Class: Card::FileCardCreator
- Inherits:
-
Object
- Object
- Card::FileCardCreator
- Defined in:
- lib/card/tasks/card/file_card_creator.rb,
lib/card/tasks/card/file_card_creator/haml_card.rb,
lib/card/tasks/card/file_card_creator/style_card.rb,
lib/card/tasks/card/file_card_creator/script_card.rb,
lib/card/tasks/card/file_card_creator/output_helper.rb,
lib/card/tasks/card/file_card_creator/abstract_file_card.rb,
lib/card/tasks/card/file_card_creator/abstract_file_card/ruby_file.rb,
lib/card/tasks/card/file_card_creator/abstract_file_card/source_file.rb,
lib/card/tasks/card/file_card_creator/abstract_file_card/migration_file.rb
Overview
A Factory class It choses the class to create the file card accoring to the given type.
Defined Under Namespace
Modules: OutputHelper Classes: AbstractFileCard, HamlCard, ScriptCard, StyleCard
Constant Summary collapse
- CARD_CLASSES =
[StyleCard, ScriptCard, HamlCard].freeze
Instance Attribute Summary collapse
-
#creator ⇒ Object
readonly
Returns the value of attribute creator.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(mod, name, type, codename, force) ⇒ FileCardCreator
constructor
A new instance of FileCardCreator.
Constructor Details
#initialize(mod, name, type, codename, force) ⇒ FileCardCreator
Returns a new instance of FileCardCreator.
9 10 11 12 13 14 15 16 17 |
# File 'lib/card/tasks/card/file_card_creator.rb', line 9 def initialize mod, name, type, codename, force card_class = FileCardCreator.card_class type unless card_class raise "'#{type}' is not a valid type. "\ "Please choose between js, coffee, css, scss and haml", :red end @creator = card_class.new mod, name, type, codename: codename, force: force end |
Instance Attribute Details
#creator ⇒ Object (readonly)
Returns the value of attribute creator.
7 8 9 |
# File 'lib/card/tasks/card/file_card_creator.rb', line 7 def creator @creator end |
Class Method Details
.card_class(type) ⇒ Object
18 19 20 21 |
# File 'lib/card/tasks/card/file_card_creator.rb', line 18 def self.card_class type CARD_CLASSES.find { |cc| cc.valid_type? type } end |