Class: Twittbot::TemplateLister

Inherits:
Object
  • Object
show all
Includes:
Thor::Shell
Defined in:
lib/twittbot/template_lister.rb

Overview

Class to list available templates

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ TemplateLister

Returns a new instance of TemplateLister.

Parameters:

  • options (Hash)

    The CLI options from Thor



7
8
9
10
# File 'lib/twittbot/template_lister.rb', line 7

def initialize(options)
  @options = {}.merge(options)
  @options['templates_dir'] = File.expand_path "../generators/templates", __FILE__
end

Instance Method Details

#listObject

Prints the available templates to stdout.



13
14
15
16
17
18
19
20
# File 'lib/twittbot/template_lister.rb', line 13

def list
  dirs = Dir["#{@options['templates_dir']}/*"]
  dirs.each do |dir|
    if File.exist? dir and File.directory? dir
      say File.basename(dir).gsub('_', '-')
    end
  end
end