Class: Genit::BuilderBase

Inherits:
Object
  • Object
show all
Defined in:
lib/genit/builders/builder_base.rb

Overview

A base class for all builders.

Direct Known Subclasses

MenuBuilder, Relativizer

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(doc) ⇒ BuilderBase

Public: Constructor.

doc - A Nokogiri::XML::Document

Raises:

  • (RuntimeError)


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

Raises:

  • (NotImplementedError)


19
20
21
# File 'lib/genit/builders/builder_base.rb', line 19

def build_for_page page_name
  raise NotImplementedError
end