Sha256: fb4eafd4d6fe9a74e1966a34a1b59b3c462a1180d16be24e59cddcf6c2d530b2

Contents?: true

Size: 707 Bytes

Versions: 25

Compression:

Stored size: 707 Bytes

Contents

class Card
  # A Factory class
  # It choses the class to create the file card accoring 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

25 entries across 25 versions & 1 rubygems

Version Path
card-1.96.8 lib/card/tasks/card/file_card_creator.rb
card-1.96.7 lib/card/tasks/card/file_card_creator.rb
card-1.96.6 lib/card/tasks/card/file_card_creator.rb
card-1.96.5 lib/card/tasks/card/file_card_creator.rb
card-1.96.4 lib/card/tasks/card/file_card_creator.rb
card-1.96.3 lib/card/tasks/card/file_card_creator.rb
card-1.96.2 lib/card/tasks/card/file_card_creator.rb
card-1.96.1 lib/card/tasks/card/file_card_creator.rb
card-1.96.0 lib/card/tasks/card/file_card_creator.rb
card-1.95.3 lib/card/tasks/card/file_card_creator.rb
card-1.95.2 lib/card/tasks/card/file_card_creator.rb
card-1.95.1 lib/card/tasks/card/file_card_creator.rb
card-1.95.0 lib/card/tasks/card/file_card_creator.rb
card-1.94.1 lib/card/tasks/card/file_card_creator.rb
card-1.94.0 lib/card/tasks/card/file_card_creator.rb
card-1.93.13 lib/card/tasks/card/file_card_creator.rb
card-1.93.12 lib/card/tasks/card/file_card_creator.rb
card-1.93.11 lib/card/tasks/card/file_card_creator.rb
card-1.93.10 lib/card/tasks/card/file_card_creator.rb
card-1.93.9 lib/card/tasks/card/file_card_creator.rb