Class: Bunto::Excerpt
- Inherits:
-
Object
- Object
- Bunto::Excerpt
- Extended by:
- Forwardable
- Defined in:
- lib/bunto/excerpt.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#doc ⇒ Object
Returns the value of attribute doc.
-
#ext ⇒ Object
Returns the value of attribute ext.
- #output ⇒ Object
Instance Method Summary collapse
-
#data ⇒ Object
Fetch YAML front-matter data from related doc, without layout key.
-
#id ⇒ Object
The UID for this doc (useful in feeds).
-
#include?(something) ⇒ Boolean
Check if excerpt includes a string.
-
#initialize(doc) ⇒ Excerpt
constructor
Initialize this Excerpt instance.
-
#inspect ⇒ Object
Returns the shorthand String identifier of this doc.
-
#path ⇒ Object
‘Path’ of the excerpt.
- #place_in_layout? ⇒ Boolean
- #to_liquid ⇒ Object
- #to_s ⇒ Object
- #trigger_hooks ⇒ Object
Constructor Details
#initialize(doc) ⇒ Excerpt
Initialize this Excerpt instance.
doc - The Document.
Returns the new Excerpt.
18 19 20 21 |
# File 'lib/bunto/excerpt.rb', line 18 def initialize(doc) self.doc = doc self.content = extract_excerpt(doc.content) end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
6 7 8 |
# File 'lib/bunto/excerpt.rb', line 6 def content @content end |
#doc ⇒ Object
Returns the value of attribute doc.
5 6 7 |
# File 'lib/bunto/excerpt.rb', line 5 def doc @doc end |
#ext ⇒ Object
Returns the value of attribute ext.
6 7 8 |
# File 'lib/bunto/excerpt.rb', line 6 def ext @ext end |
Instance Method Details
#data ⇒ Object
Fetch YAML front-matter data from related doc, without layout key
Returns Hash of doc data
26 27 28 29 30 31 |
# File 'lib/bunto/excerpt.rb', line 26 def data @data ||= doc.data.dup @data.delete("layout") @data.delete("excerpt") @data end |
#id ⇒ Object
The UID for this doc (useful in feeds). e.g. /2008/11/05/my-awesome-doc
Returns the String UID.
54 55 56 |
# File 'lib/bunto/excerpt.rb', line 54 def id "#{doc.id}#excerpt" end |
#include?(something) ⇒ Boolean
Check if excerpt includes a string
Returns true if the string passed in
46 47 48 |
# File 'lib/bunto/excerpt.rb', line 46 def include?(something) (output && output.include?(something)) || content.include?(something) end |
#inspect ⇒ Object
Returns the shorthand String identifier of this doc.
67 68 69 |
# File 'lib/bunto/excerpt.rb', line 67 def inspect "<Excerpt: #{self.id}>" end |
#path ⇒ Object
‘Path’ of the excerpt.
Returns the path for the doc this excerpt belongs to with #excerpt appended
39 40 41 |
# File 'lib/bunto/excerpt.rb', line 39 def path File.join(doc.path, "#excerpt") end |
#place_in_layout? ⇒ Boolean
75 76 77 |
# File 'lib/bunto/excerpt.rb', line 75 def place_in_layout? false end |
#to_liquid ⇒ Object
62 63 64 |
# File 'lib/bunto/excerpt.rb', line 62 def to_liquid Bunto::Drops::ExcerptDrop.new(self) end |
#to_s ⇒ Object
58 59 60 |
# File 'lib/bunto/excerpt.rb', line 58 def to_s output || content end |
#trigger_hooks ⇒ Object
33 34 |
# File 'lib/bunto/excerpt.rb', line 33 def trigger_hooks(*) end |