Class: ContentsGenerator
- Inherits:
-
Object
- Object
- ContentsGenerator
- Defined in:
- lib/contents_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #get_commands ⇒ Object
-
#initialize ⇒ ContentsGenerator
constructor
A new instance of ContentsGenerator.
- #switch ⇒ Object
Constructor Details
#initialize ⇒ ContentsGenerator
8 9 10 11 12 |
# File 'lib/contents_generator.rb', line 8 def initialize @command = ARGV.shift @argv = ARGV @commands = get_commands end |
Class Method Details
.boot ⇒ Object
14 15 16 |
# File 'lib/contents_generator.rb', line 14 def self.boot new.switch end |
Instance Method Details
#get_commands ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/contents_generator.rb', line 26 def get_commands commands = [] Dir.entries(CG_LIB).each do |file| commands << file.gsub!('.rb', '') if file =~ /rb/ end commands end |
#switch ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/contents_generator.rb', line 18 def switch if @commands.include? @command exec("ruby #{CG_LIB}/#{@command}.rb #{@argv.join(' ')}") else puts OptionParser.new("Usage: cg [#{@commands.join('|')}]").help end end |