Class: Card::FileCardCreator::AbstractFileCard

Inherits:
Object
  • Object
show all
Includes:
MigrationFile, RubyFile, SourceFile, OutputHelper
Defined in:
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 template class for generating cards that are linked to source files.

Direct Known Subclasses

HamlCard, ScriptCard, StyleCard

Defined Under Namespace

Modules: MigrationFile, RubyFile, SourceFile

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RubyFile

#create_ruby_file

Methods included from MigrationFile

#create_migration_file

Methods included from SourceFile

#create_source_file

Methods included from OutputHelper

#color_puts, #log_file_action, #write_at, #write_to_mod

Constructor Details

#initialize(mod, name, type, codename: nil, force: false) ⇒ AbstractFileCard

Returns a new instance of AbstractFileCard.



24
25
26
27
28
29
30
# File 'lib/card/tasks/card/file_card_creator/abstract_file_card.rb', line 24

def initialize mod, name, type, codename: nil, force: false
  @mod = mod
  @type = type.to_sym
  @name = name
  @force = force
  @codename = codename || name.underscore.tr(" ", "_")
end

Class Attribute Details

.categoryObject (readonly)

Returns the value of attribute category.



16
17
18
# File 'lib/card/tasks/card/file_card_creator/abstract_file_card.rb', line 16

def category
  @category
end

.default_rule_nameObject

Returns the value of attribute default_rule_name.



17
18
19
# File 'lib/card/tasks/card/file_card_creator/abstract_file_card.rb', line 17

def default_rule_name
  @default_rule_name
end

.supported_typesObject (readonly)

Returns the value of attribute supported_types.



16
17
18
# File 'lib/card/tasks/card/file_card_creator/abstract_file_card.rb', line 16

def supported_types
  @supported_types
end

Class Method Details

.valid_type?(type) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/card/tasks/card/file_card_creator/abstract_file_card.rb', line 19

def valid_type? type
  supported_types.include? type.to_sym
end

Instance Method Details

#categoryObject



38
39
40
# File 'lib/card/tasks/card/file_card_creator/abstract_file_card.rb', line 38

def category
  self.class.category
end

#createObject



32
33
34
35
36
# File 'lib/card/tasks/card/file_card_creator/abstract_file_card.rb', line 32

def create
  create_source_file
  create_ruby_file
  create_migration_file
end