Class: Genit::BuilderBase
- Inherits:
-
Object
- Object
- Genit::BuilderBase
- Defined in:
- lib/genit/builders/builder_base.rb
Overview
A base class for all builders.
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #build(page_name, elements) ⇒ Object
-
#build_for_page(page_name) ⇒ Object
Define me in child.
-
#initialize(doc) ⇒ BuilderBase
constructor
Public: Constructor.
Constructor Details
#initialize(doc) ⇒ BuilderBase
Public: Constructor.
doc - A Nokogiri::XML::Document
13 14 15 16 |
# File 'lib/genit/builders/builder_base.rb', line 13 def initialize doc raise RuntimeError if doc.nil? @document = doc end |
Class Method Details
.get_number_of_base_dirs(filename) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/genit/builders/builder_base.rb', line 29 def BuilderBase.get_number_of_base_dirs filename return 0 if filename =~ URI::regexp dirs = File.dirname filename return 0 if dirs == '.' return dirs.split('/').size end |
Instance Method Details
#build(page_name, elements) ⇒ Object
23 24 25 26 27 |
# File 'lib/genit/builders/builder_base.rb', line 23 def build page_name, elements @page_name = page_name elements.each {|elem| update elem } @document end |
#build_for_page(page_name) ⇒ Object
Define me in child
19 20 21 |
# File 'lib/genit/builders/builder_base.rb', line 19 def build_for_page page_name raise NotImplementedError end |