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
- #due? ⇒ Boolean
-
#initialize(id, desc, date = nil, tags = [], completed = false, archived = false, formatter = ItemPresenter) ⇒ Item
constructor
A new instance of Item.
- #to_h ⇒ Object
- #to_s ⇒ Object
- #toggle_archived! ⇒ Object
- #toggle_completed! ⇒ Object
Constructor Details
#initialize(id, desc, date = nil, tags = [], completed = false, archived = false, formatter = 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 = nil, = [], completed = false, archived = false, formatter = ItemPresenter) @id = id @desc = desc self.date = date # this looks ugly @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
52 53 54 |
# File 'lib/nin/item.rb', line 52 def archived? @archived end |
#completed? ⇒ Boolean
48 49 50 |
# File 'lib/nin/item.rb', line 48 def completed? @completed end |
#due? ⇒ Boolean
56 57 58 |
# File 'lib/nin/item.rb', line 56 def due? @date < Date.today.to_s end |
#to_h ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/nin/item.rb', line 38 def to_h { 'id' => id, 'desc' => desc, 'tags' => , 'completed' => completed, 'archived' => archived } end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/nin/item.rb', line 34 def to_s @formatter.call end |
#toggle_archived! ⇒ Object
30 31 32 |
# File 'lib/nin/item.rb', line 30 def toggle_archived! @archived = !@archived end |
#toggle_completed! ⇒ Object
26 27 28 |
# File 'lib/nin/item.rb', line 26 def toggle_completed! @completed = !@completed end |