Class: NamespaceEngine

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_namespace_engine.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ NamespaceEngine



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rails_namespace_engine.rb', line 8

def initialize(argv)
  argv[0] = '--help' if argv.size < 2

  if argv[0] == '--help'
    @help = true
  else
    @help = false
    @namespace = argv[0].underscore
    @engine_name = argv[1].underscore
  end
end

Instance Attribute Details

#engine_nameObject (readonly)

Returns the value of attribute engine_name.



6
7
8
# File 'lib/rails_namespace_engine.rb', line 6

def engine_name
  @engine_name
end

#helpObject (readonly)

Returns the value of attribute help.



6
7
8
# File 'lib/rails_namespace_engine.rb', line 6

def help
  @help
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



6
7
8
# File 'lib/rails_namespace_engine.rb', line 6

def namespace
  @namespace
end

Instance Method Details

#callObject



20
21
22
23
24
25
26
27
28
# File 'lib/rails_namespace_engine.rb', line 20

def call
  if help
    puts instructions
  else
    invoke_generator
    structure_files_and_directories
    file_contents
  end
end