Class: Jekyll::PDF::Partial

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/jekyll/pdf/partial.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(doc, partial) ⇒ Partial

Initialize this Partial instance.

doc - The Document.

Returns the new Partial.



23
24
25
26
27
# File 'lib/jekyll/pdf/partial.rb', line 23

def initialize(doc, partial)
  self.doc = doc
  self.partial = partial
  self.content = build_partial(partial)
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



12
13
14
# File 'lib/jekyll/pdf/partial.rb', line 12

def content
  @content
end

#docObject

Returns the value of attribute doc.



9
10
11
# File 'lib/jekyll/pdf/partial.rb', line 9

def doc
  @doc
end

#extObject

Returns the value of attribute ext.



12
13
14
# File 'lib/jekyll/pdf/partial.rb', line 12

def ext
  @ext
end

#outputObject



71
72
73
# File 'lib/jekyll/pdf/partial.rb', line 71

def output
  @output ||= Renderer.new(doc.site, self, site.site_payload).run
end

#partialObject

Returns the value of attribute partial.



10
11
12
# File 'lib/jekyll/pdf/partial.rb', line 10

def partial
  @partial
end

#writeObject

generate temp file & set output to it’s path



76
77
78
# File 'lib/jekyll/pdf/partial.rb', line 76

def write
  @write
end

Instance Method Details

#cleanObject

delete temp file



88
89
90
# File 'lib/jekyll/pdf/partial.rb', line 88

def clean
  File.delete(@output)
end

#dataObject

Fetch YAML front-matter data from related doc, without layout key

Returns Hash of doc data



32
33
34
35
36
# File 'lib/jekyll/pdf/partial.rb', line 32

def data
  @data ||= doc.data.dup
  @data.delete("layout")
  @data
end

#dirObject

Returns the cache directory



51
52
53
# File 'lib/jekyll/pdf/partial.rb', line 51

def dir
  @dir ||= cache_dir
end

#filenameObject

Returns the file name for the temporary file



46
47
48
# File 'lib/jekyll/pdf/partial.rb', line 46

def filename
  File.basename(path, File.extname(path)) + "-" + Digest::MD5.hexdigest(to_s) + File.extname(path)
end

#inspectObject

Returns the shorthand String identifier of this doc.



67
68
69
# File 'lib/jekyll/pdf/partial.rb', line 67

def inspect
  "<Partial: #{self.id}>"
end

#pathObject



41
42
43
# File 'lib/jekyll/pdf/partial.rb', line 41

def path
  File.join(doc.path, partial)
end

#place_in_layout?Boolean

Returns:

  • (Boolean)


92
93
94
# File 'lib/jekyll/pdf/partial.rb', line 92

def place_in_layout?
  false
end

#to_liquidObject



59
60
61
62
63
64
# File 'lib/jekyll/pdf/partial.rb', line 59

def to_liquid
  doc.data[partial] = nil
  @to_liquid ||= doc.to_liquid
  doc.data[partial] = self
  @to_liquid
end

#to_sObject



55
56
57
# File 'lib/jekyll/pdf/partial.rb', line 55

def to_s
  output || content
end

#trigger_hooksObject



38
39
# File 'lib/jekyll/pdf/partial.rb', line 38

def trigger_hooks(*)
end