Class: EhbrsRubyUtils::CookingBook::Build::BasePage

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/ehbrs_ruby_utils/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.



11
12
13
14
# File 'lib/ehbrs_ruby_utils/cooking_book/build/base_page.rb', line 11

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

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent.



9
10
11
# File 'lib/ehbrs_ruby_utils/cooking_book/build/base_page.rb', line 9

def parent
  @parent
end

Instance Method Details

#buildObject



16
17
18
# File 'lib/ehbrs_ruby_utils/cooking_book/build/base_page.rb', line 16

def build
  target_path.write(target_content)
end

#erb_result(template_basename, template_source = self) ⇒ Object



36
37
38
# File 'lib/ehbrs_ruby_utils/cooking_book/build/base_page.rb', line 36

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

#hrefObject



20
21
22
# File 'lib/ehbrs_ruby_utils/cooking_book/build/base_page.rb', line 20

def href
  "#{target_basename}.html"
end

#inner_contentObject



32
33
34
# File 'lib/ehbrs_ruby_utils/cooking_book/build/base_page.rb', line 32

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

#target_contentObject



28
29
30
# File 'lib/ehbrs_ruby_utils/cooking_book/build/base_page.rb', line 28

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

#target_pathObject



24
25
26
# File 'lib/ehbrs_ruby_utils/cooking_book/build/base_page.rb', line 24

def target_path
  parent.target_dir.join(href)
end