Sha256: 714dc6d33bee4c2d6f83f24f42026c2fb5372b4db350104e704fe0051b9a90b4
Contents?: true
Size: 918 Bytes
Versions: 19
Compression:
Stored size: 918 Bytes
Contents
require_relative "./file_card_creator/script_card" require_relative "./file_card_creator/style_card" require_relative "./file_card_creator/haml_card" require_relative "./file_card_creator/abstract_file_card" class Card # A Factory class # It chooses the class to create the file card according to the given type. class FileCardCreator CARD_CLASSES = [StyleCard, ScriptCard, HamlCard].freeze attr_reader :creator 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 def self.card_class type CARD_CLASSES.find { |cc| cc.valid_type? type } end delegate :create, to: :creator end end
Version data entries
19 entries across 19 versions & 1 rubygems