Class: Jekyll::Excerpt

Inherits:
Object
  • Object
show all
Includes:
Convertible
Defined in:
lib/jekyll/excerpt.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Convertible

#converter, #do_layout, #output_ext, #read_yaml, #render_all_layouts, #render_liquid, #transform, #write

Constructor Details

#initialize(post) ⇒ Excerpt

Initialize this Post instance.

site - The Site. base - The String path to the dir containing the post file. name - The String filename of the post file.

Returns the new Post.



15
16
17
18
# File 'lib/jekyll/excerpt.rb', line 15

def initialize(post)
  self.post = post
  self.content = extract_excerpt(post.content)
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



6
7
8
# File 'lib/jekyll/excerpt.rb', line 6

def content
  @content
end

#extObject

Returns the value of attribute ext.



6
7
8
# File 'lib/jekyll/excerpt.rb', line 6

def ext
  @ext
end

#outputObject

Returns the value of attribute output.



6
7
8
# File 'lib/jekyll/excerpt.rb', line 6

def output
  @output
end

#postObject

Returns the value of attribute post.



5
6
7
# File 'lib/jekyll/excerpt.rb', line 5

def post
  @post
end

Instance Method Details

#dataObject

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

Returns Hash of post data



33
34
35
36
37
# File 'lib/jekyll/excerpt.rb', line 33

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

#idObject

The UID for this post (useful in feeds). e.g. /2008/11/05/my-awesome-post

Returns the String UID.



57
58
59
# File 'lib/jekyll/excerpt.rb', line 57

def id
  File.join(post.dir, post.slug, "#excerpt")
end

#include?(something) ⇒ Boolean

Check if excerpt includes a string

Returns true if the string passed in

Returns:

  • (Boolean)


49
50
51
# File 'lib/jekyll/excerpt.rb', line 49

def include?(something)
  (self.output && self.output.include?(something)) || self.content.include?(something)
end

#inspectObject

Returns the shorthand String identifier of this Post.



66
67
68
# File 'lib/jekyll/excerpt.rb', line 66

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

#pathObject

‘Path’ of the excerpt.

Returns the path for the post this excerpt belongs to with #excerpt appended



42
43
44
# File 'lib/jekyll/excerpt.rb', line 42

def path
  File.join(post.path, "#excerpt")
end

#to_liquidObject



26
27
28
# File 'lib/jekyll/excerpt.rb', line 26

def to_liquid
  post.to_liquid(Post::EXCERPT_ATTRIBUTES_FOR_LIQUID)
end

#to_sObject



61
62
63
# File 'lib/jekyll/excerpt.rb', line 61

def to_s
  self.output || self.content
end