Class: Retter::Entry
- Inherits:
-
Object
- Object
- Retter::Entry
- Defined in:
- lib/retter/entry.rb
Defined Under Namespace
Classes: Article
Instance Attribute Summary collapse
-
#articles ⇒ Object
Returns the value of attribute articles.
-
#body ⇒ Object
Returns the value of attribute body.
-
#date ⇒ Object
Returns the value of attribute date.
-
#lede ⇒ Object
Returns the value of attribute lede.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #index ⇒ Object
-
#initialize(attrs = {}) ⇒ Entry
constructor
A new instance of Entry.
- #next ⇒ Object
- #prev ⇒ Object
- #to_article ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ Entry
Returns a new instance of Entry.
55 56 57 58 59 60 61 62 63 |
# File 'lib/retter/entry.rb', line 55 def initialize(attrs = {}) @entries, @date, @body = attrs.values_at(:entries, :date, :body) path_by_date = Entries.retters_dir.join(date.strftime('%Y%m%d.md')) @path = attrs[:path] || path_by_date extract_articles assign_lede end |
Instance Attribute Details
#articles ⇒ Object
Returns the value of attribute articles.
52 53 54 |
# File 'lib/retter/entry.rb', line 52 def articles @articles end |
#body ⇒ Object
Returns the value of attribute body.
52 53 54 |
# File 'lib/retter/entry.rb', line 52 def body @body end |
#date ⇒ Object
Returns the value of attribute date.
52 53 54 |
# File 'lib/retter/entry.rb', line 52 def date @date end |
#lede ⇒ Object
Returns the value of attribute lede.
52 53 54 |
# File 'lib/retter/entry.rb', line 52 def lede @lede end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
53 54 55 |
# File 'lib/retter/entry.rb', line 53 def path @path end |
Instance Method Details
#index ⇒ Object
77 78 79 |
# File 'lib/retter/entry.rb', line 77 def index @entries.index(self) || 0 end |
#next ⇒ Object
69 70 71 |
# File 'lib/retter/entry.rb', line 69 def next @entries[index.next] end |
#prev ⇒ Object
73 74 75 |
# File 'lib/retter/entry.rb', line 73 def prev @entries[index.pred] unless index.pred < 0 end |
#to_article ⇒ Object
81 82 83 |
# File 'lib/retter/entry.rb', line 81 def to_article Article.new(entry: self, id: 'a0', title: date.to_s, body: body, actual: false) end |
#to_s ⇒ Object
65 66 67 |
# File 'lib/retter/entry.rb', line 65 def to_s body end |