Class: Sticky::Note
- Inherits:
-
Object
- Object
- Sticky::Note
- Defined in:
- lib/sticky/note.rb
Instance Attribute Summary collapse
-
#db ⇒ Object
Returns the value of attribute db.
-
#message ⇒ Object
Returns the value of attribute message.
-
#tag ⇒ Object
Returns the value of attribute tag.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
Class Method Summary collapse
- .build(message, tag = nil, db = Sticky::Store.new) ⇒ Object
- .delete!(tag, db = Sticky::Store.new) ⇒ Object
- .show(tag, db = Sticky::Store.new) ⇒ Object
Instance Method Summary collapse
-
#initialize(message, tag, db, timestamp = Time.now) ⇒ Note
constructor
A new instance of Note.
- #save! ⇒ Object
- #to_yaml_properties ⇒ Object
Constructor Details
#initialize(message, tag, db, timestamp = Time.now) ⇒ Note
Returns a new instance of Note.
21 22 23 24 25 26 |
# File 'lib/sticky/note.rb', line 21 def initialize(, tag, db, = Time.now) @message = @db = db @tag = tag @timestamp = end |
Instance Attribute Details
#db ⇒ Object
Returns the value of attribute db.
3 4 5 |
# File 'lib/sticky/note.rb', line 3 def db @db end |
#message ⇒ Object
Returns the value of attribute message.
3 4 5 |
# File 'lib/sticky/note.rb', line 3 def @message end |
#tag ⇒ Object
Returns the value of attribute tag.
3 4 5 |
# File 'lib/sticky/note.rb', line 3 def tag @tag end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
3 4 5 |
# File 'lib/sticky/note.rb', line 3 def @timestamp end |
Class Method Details
.build(message, tag = nil, db = Sticky::Store.new) ⇒ Object
6 7 8 |
# File 'lib/sticky/note.rb', line 6 def build(, tag = nil, db = Sticky::Store.new) new(, tag, db) end |
.delete!(tag, db = Sticky::Store.new) ⇒ Object
16 17 18 |
# File 'lib/sticky/note.rb', line 16 def delete!(tag, db = Sticky::Store.new) db.delete!(tag) end |
.show(tag, db = Sticky::Store.new) ⇒ Object
10 11 12 13 14 |
# File 'lib/sticky/note.rb', line 10 def show(tag, db = Sticky::Store.new) db.fetch(tag) do |note| puts note end end |
Instance Method Details
#save! ⇒ Object
28 29 30 |
# File 'lib/sticky/note.rb', line 28 def save! db.save!(self) end |
#to_yaml_properties ⇒ Object
32 33 34 |
# File 'lib/sticky/note.rb', line 32 def to_yaml_properties [:@message, :@tag, :@timestamp] end |