Class: JekyllPagesApi::GeneratedPage

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll_pages_api/generated_page.rb

Overview

Used by GeneratedSite to mimic a Jekyll page object when processing an already-generated site using the Generator.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, basedir, title_prefix, body_element_tag, content) ⇒ GeneratedPage

Returns a new instance of GeneratedPage.

Parameters:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/jekyll_pages_api/generated_page.rb', line 17

def initialize(path, basedir, title_prefix, body_element_tag, content)
  unless path.start_with? basedir
    raise "#{path} does not start with #{basedir}"
  end

  @path = path
  basedir_len = basedir.size
  basedir_len -= File::SEPARATOR.size if basedir.end_with? File::SEPARATOR

  end_path = path.size
  index_suffix = File.join "", "index.html"
  end_path -= index_suffix.size if path.end_with? index_suffix
  @relative_path = (path[basedir_len..end_path] || "")
  @data, @content = GeneratedPageParser.parse_generated_page(
    content, title_prefix, body_element_tag)
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



9
10
11
# File 'lib/jekyll_pages_api/generated_page.rb', line 9

def content
  @content
end

#dataObject (readonly)

Returns the value of attribute data.



9
10
11
# File 'lib/jekyll_pages_api/generated_page.rb', line 9

def data
  @data
end

#pathObject (readonly)

Returns the value of attribute path.



9
10
11
# File 'lib/jekyll_pages_api/generated_page.rb', line 9

def path
  @path
end

#relative_pathObject (readonly)

Returns the value of attribute relative_path.



9
10
11
# File 'lib/jekyll_pages_api/generated_page.rb', line 9

def relative_path
  @relative_path
end