Class: Yuzu::Generators::PaginateGenerator
- Defined in:
- lib/yuzu/generators/paginate.rb
Constant Summary collapse
- @@generated =
[]
Instance Attribute Summary
Attributes inherited from Generator
Class Method Summary collapse
Instance Method Summary collapse
- #generate!(website_file) ⇒ Object
-
#initialize ⇒ PaginateGenerator
constructor
A new instance of PaginateGenerator.
- #should_generate?(website_file) ⇒ Boolean
- #visitor_filter ⇒ Object
Methods inherited from Generator
Constructor Details
#initialize ⇒ PaginateGenerator
Returns a new instance of PaginateGenerator.
21 22 23 24 |
# File 'lib/yuzu/generators/paginate.rb', line 21 def initialize @name = "paginate" @directive = "INSERTCATALOG" end |
Class Method Details
.add_generator(generator) ⇒ Object
13 14 15 |
# File 'lib/yuzu/generators/paginate.rb', line 13 def self.add_generator(generator) @@generated.push(generator) end |
.get_generated ⇒ Object
9 10 11 |
# File 'lib/yuzu/generators/paginate.rb', line 9 def self.get_generated @@generated end |
.is_generated?(generator) ⇒ Boolean
17 18 19 |
# File 'lib/yuzu/generators/paginate.rb', line 17 def self.is_generated?(generator) @@generated.include?(generator) end |
Instance Method Details
#generate!(website_file) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/yuzu/generators/paginate.rb', line 35 def generate!(website_file) # Attempt to ensure this website_file isn't generated twice. return if website_file.is_a?(Yuzu::Core::PaginatedWebsiteFile) or \ PaginateGenerator.is_generated?(website_file) CatalogPaginator.new(website_file, self).generate! PaginateGenerator.add_generator(website_file) end |
#should_generate?(website_file) ⇒ Boolean
26 27 28 29 |
# File 'lib/yuzu/generators/paginate.rb', line 26 def should_generate?(website_file) not PaginateGenerator.is_generated?(website_file) and \ not website_file.raw_contents.scan(regex).flatten.empty? end |
#visitor_filter ⇒ Object
31 32 33 |
# File 'lib/yuzu/generators/paginate.rb', line 31 def visitor_filter proc {|c| c.file?} end |