Class: Nin::Item
- Inherits:
-
Object
- Object
- Nin::Item
- Defined in:
- lib/nin/item.rb
Instance Attribute Summary collapse
-
#archived ⇒ Object
Returns the value of attribute archived.
-
#completed ⇒ Object
Returns the value of attribute completed.
-
#date ⇒ Object
Returns the value of attribute date.
-
#desc ⇒ Object
Returns the value of attribute desc.
-
#id ⇒ Object
Returns the value of attribute id.
-
#tags ⇒ Object
Returns the value of attribute tags.
Instance Method Summary collapse
- #archived? ⇒ Boolean
- #completed? ⇒ Boolean
- #edit(desc, date = nil, tags = []) ⇒ Object
-
#initialize(id, desc, date = Date.today, tags = [], completed = false, archived = false, formatter = Presenter::ItemPresenter) ⇒ Item
constructor
A new instance of Item.
- #past? ⇒ Boolean
- #to_h ⇒ Object
- #to_s ⇒ Object
- #today? ⇒ Boolean
- #toggle_archived! ⇒ Object
- #toggle_completed! ⇒ Object
Constructor Details
#initialize(id, desc, date = Date.today, tags = [], completed = false, archived = false, formatter = Presenter::ItemPresenter) ⇒ Item
Returns a new instance of Item.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/nin/item.rb', line 5 def initialize(id, desc, date = Date.today, = [], completed = false, archived = false, formatter = Presenter::ItemPresenter) @id = id @desc = desc @date = Date.parse_or_return(date) || Date.today @tags = @completed = completed @archived = archived @formatter = formatter.new(self) end |
Instance Attribute Details
#archived ⇒ Object
Returns the value of attribute archived.
3 4 5 |
# File 'lib/nin/item.rb', line 3 def archived @archived end |
#completed ⇒ Object
Returns the value of attribute completed.
3 4 5 |
# File 'lib/nin/item.rb', line 3 def completed @completed end |
#date ⇒ Object
Returns the value of attribute date.
3 4 5 |
# File 'lib/nin/item.rb', line 3 def date @date end |
#desc ⇒ Object
Returns the value of attribute desc.
3 4 5 |
# File 'lib/nin/item.rb', line 3 def desc @desc end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/nin/item.rb', line 3 def id @id end |
#tags ⇒ Object
Returns the value of attribute tags.
3 4 5 |
# File 'lib/nin/item.rb', line 3 def @tags end |
Instance Method Details
#archived? ⇒ Boolean
40 41 42 |
# File 'lib/nin/item.rb', line 40 def archived? @archived end |
#completed? ⇒ Boolean
36 37 38 |
# File 'lib/nin/item.rb', line 36 def completed? @completed end |
#edit(desc, date = nil, tags = []) ⇒ Object
22 23 24 25 26 |
# File 'lib/nin/item.rb', line 22 def edit(desc, date = nil, = []) self.desc = desc self.date = date unless date.nil? self..concat() end |
#to_h ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/nin/item.rb', line 56 def to_h { 'id' => id, 'desc' => desc, 'tags' => , 'completed' => completed, 'archived' => archived } end |
#to_s ⇒ Object
52 53 54 |
# File 'lib/nin/item.rb', line 52 def to_s @formatter.call end |
#toggle_archived! ⇒ Object
32 33 34 |
# File 'lib/nin/item.rb', line 32 def toggle_archived! @archived = !@archived end |
#toggle_completed! ⇒ Object
28 29 30 |
# File 'lib/nin/item.rb', line 28 def toggle_completed! @completed = !@completed end |