Class: Templatron::Collector
- Inherits:
-
Object
- Object
- Templatron::Collector
- Defined in:
- lib/templatron/collector.rb
Overview
Collector stuff Show templates and related informations
Instance Attribute Summary collapse
-
#full_path ⇒ Object
Returns the value of attribute full_path.
Instance Method Summary collapse
-
#initialize(path, include_files, include_sub, verbose = false) ⇒ Collector
constructor
Public: Initialize the collector instance.
-
#list ⇒ Object
Public: List the content of this template.
Constructor Details
#initialize(path, include_files, include_sub, verbose = false) ⇒ Collector
Public: Initialize the collector instance
path - Relative path of a template include_files - Also include files or not include_sub - Incluse subfolders? verbose - Verbose mode?
18 19 20 21 22 23 |
# File 'lib/templatron/collector.rb', line 18 def initialize(path, include_files, include_sub, verbose = false) @full_path = File.join(Templatron::templates_path, (path)) @verbose = verbose @include_files = include_files @include_subfolders = include_sub end |
Instance Attribute Details
#full_path ⇒ Object
Returns the value of attribute full_path.
10 11 12 |
# File 'lib/templatron/collector.rb', line 10 def full_path @full_path end |
Instance Method Details
#list ⇒ Object
Public: List the content of this template
Returns the list of entries for this instance
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/templatron/collector.rb', line 28 def list puts "Listing content: of directory #{@full_path}" if @verbose v = ['**'] v << '*' if @include_subfolders entries = Dir.glob(escape_glob(File.join(@full_path, v))) entries.map! { |e| e if File.directory?(e) }.compact! if !@include_files entries end |