Class: Yuzu::Core::PaginatedWebsiteFile

Inherits:
WebsiteFile show all
Defined in:
lib/yuzu/core/paginated_file.rb

Constant Summary

Constants included from Yuzu::Core

BOLD, ENDC, WHITE

Instance Attribute Summary collapse

Attributes inherited from WebsiteFile

#page, #parent, #path

Attributes inherited from WebsiteBase

#kind, #parent, #path

Instance Method Summary collapse

Methods inherited from WebsiteFile

#author, #basename, #contents, #filename, #filters, #get_prefiltered_contents, #get_processed_contents, #home?, #html_contents, #index?, #layout, #layout_contents, #link_root, #mainfilters, #markdown?, #name, #output_filename, #plaintext?, #postfilters, #prefiltered_contents, #prefilters, #preprocess!, #processed_contents, processors, #properties, #raw_contents, #rendered_contents, translators

Methods included from Filters

catalog_for, get_kwds

Methods included from Yuzu::Core

get_paginated_path

Methods inherited from WebsiteBase

#==, #asset?, #blog_folder, #children, #config, #default_stash, #file?, #folder?, #get_link_url, #get_remote_path, #hidden?, #image?, #in_blog?, #index?, #is_blog?, #is_processable?, #link_to_self, #link_url, #name, #processable?, #remote_path, #resource?, #root, #root?, #stash

Constructor Details

#initialize(original_file, new_raw_contents, page) ⇒ PaginatedWebsiteFile

Initialize a new generated file from an existing WebsiteFile

Parameters:

  • original_file (WebsiteFile)

    The root file representing page 1.

  • new_raw_contents (String)

    The new contents with the INSERTCATALOG directives updated to include the page:N argument.

  • page (Fixnum)

    The page that this generated file represents.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/yuzu/core/paginated_file.rb', line 13

def initialize(original_file, new_raw_contents, page)
  @raw_contents = new_raw_contents
  @page = page

  @path = Yuzu::Core.get_paginated_path(original_file.path, page)
  raise "@path is nil in #{self}" if @path.nil?

  @original_file = original_file
  @parent = original_file.parent
  @kind = :file
end

Instance Attribute Details

#original_fileObject (readonly)

Returns the value of attribute original_file.



5
6
7
# File 'lib/yuzu/core/paginated_file.rb', line 5

def original_file
  @original_file
end

Instance Method Details

#created_atObject



37
38
39
# File 'lib/yuzu/core/paginated_file.rb', line 37

def created_at
  @original_file.created_at
end

#generated?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/yuzu/core/paginated_file.rb', line 45

def generated?
  true
end

#get_raw_contentsObject



29
30
31
# File 'lib/yuzu/core/paginated_file.rb', line 29

def get_raw_contents
  @raw_contents
end

#load_file_info!Object



41
42
43
# File 'lib/yuzu/core/paginated_file.rb', line 41

def load_file_info!
  # No need to do anything here. All dependent methods are overridden.
end

#modified_atObject



33
34
35
# File 'lib/yuzu/core/paginated_file.rb', line 33

def modified_at
  @original_file.modified_at
end

#paginated?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/yuzu/core/paginated_file.rb', line 49

def paginated?
  true
end

#to_sObject



25
26
27
# File 'lib/yuzu/core/paginated_file.rb', line 25

def to_s
  "PaginatedWebsiteFile(#{@path.relative})"
end