Class: Ehbrs::CookingBook::Build::BasePage

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/ehbrs/cooking_book/build/base_page.rb

Direct Known Subclasses

IndexPage, RecipePage

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, source_object) ⇒ BasePage

Returns a new instance of BasePage.



12
13
14
15
# File 'lib/ehbrs/cooking_book/build/base_page.rb', line 12

def initialize(parent, source_object)
  super(source_object)
  @parent = parent
end

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent.



10
11
12
# File 'lib/ehbrs/cooking_book/build/base_page.rb', line 10

def parent
  @parent
end

Instance Method Details

#buildObject



17
18
19
# File 'lib/ehbrs/cooking_book/build/base_page.rb', line 17

def build
  target_path.write(target_content)
end

#erb_result(template_basename, template_source = self) ⇒ Object



37
38
39
# File 'lib/ehbrs/cooking_book/build/base_page.rb', line 37

def erb_result(template_basename, template_source = self)
  template_source.erb_template("#{template_basename}.html.erb", self)
end

#hrefObject



21
22
23
# File 'lib/ehbrs/cooking_book/build/base_page.rb', line 21

def href
  "#{target_basename}.html"
end

#inner_contentObject



33
34
35
# File 'lib/ehbrs/cooking_book/build/base_page.rb', line 33

def inner_content
  erb_result('inner', self.class)
end

#target_contentObject



29
30
31
# File 'lib/ehbrs/cooking_book/build/base_page.rb', line 29

def target_content
  erb_result('layout', ::Ehbrs::CookingBook::Build::BasePage)
end

#target_pathObject



25
26
27
# File 'lib/ehbrs/cooking_book/build/base_page.rb', line 25

def target_path
  parent.target_dir.join(href)
end