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.



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

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

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent.



7
8
9
# File 'lib/ehbrs_ruby_utils/cooking_book/build/base_page.rb', line 7

def parent
  @parent
end

Instance Method Details

#buildObject



14
15
16
# File 'lib/ehbrs_ruby_utils/cooking_book/build/base_page.rb', line 14

def build
  target_path.write(target_content)
end

#erb_result(template_basename, template_source = self) ⇒ Object



34
35
36
# File 'lib/ehbrs_ruby_utils/cooking_book/build/base_page.rb', line 34

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

#hrefObject



18
19
20
# File 'lib/ehbrs_ruby_utils/cooking_book/build/base_page.rb', line 18

def href
  "#{target_basename}.html"
end

#inner_contentObject



30
31
32
# File 'lib/ehbrs_ruby_utils/cooking_book/build/base_page.rb', line 30

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

#target_contentObject



26
27
28
# File 'lib/ehbrs_ruby_utils/cooking_book/build/base_page.rb', line 26

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

#target_pathObject



22
23
24
# File 'lib/ehbrs_ruby_utils/cooking_book/build/base_page.rb', line 22

def target_path
  parent.target_dir.join(href)
end