Class: NoteMeta
- Inherits:
-
Object
- Object
- NoteMeta
- Defined in:
- lib/yinx/note_meta.rb
Instance Method Summary collapse
- #book ⇒ Object
- #created_at ⇒ Object
-
#initialize(meta, note_store) ⇒ NoteMeta
constructor
A new instance of NoteMeta.
- #marshal_dump ⇒ Object
- #marshal_load(hash) ⇒ Object
- #stack ⇒ Object
- #tags ⇒ Object
- #to_h ⇒ Object
- #updated_at ⇒ Object
Constructor Details
#initialize(meta, note_store) ⇒ NoteMeta
Returns a new instance of NoteMeta.
17 18 19 20 |
# File 'lib/yinx/note_meta.rb', line 17 def initialize , note_store = @store = note_store end |
Instance Method Details
#book ⇒ Object
26 27 28 |
# File 'lib/yinx/note_meta.rb', line 26 def book @book ||= @store.book_name notebookGuid end |
#created_at ⇒ Object
34 35 36 |
# File 'lib/yinx/note_meta.rb', line 34 def created_at Time.at created / 1000 end |
#marshal_dump ⇒ Object
48 49 50 |
# File 'lib/yinx/note_meta.rb', line 48 def marshal_dump to_h end |
#marshal_load(hash) ⇒ Object
52 53 54 55 56 |
# File 'lib/yinx/note_meta.rb', line 52 def marshal_load hash hash.each do |key, value| instance_variable_set "@#{key}", value end end |
#stack ⇒ Object
30 31 32 |
# File 'lib/yinx/note_meta.rb', line 30 def stack @stack = (instance_variable_defined? :@stack) ? @stack : @store.stack_name(notebookGuid) end |
#tags ⇒ Object
22 23 24 |
# File 'lib/yinx/note_meta.rb', line 22 def ||= (tagGuids ? tagGuids.map{|id| @store.tag_name id} : []) end |
#to_h ⇒ Object
42 43 44 45 46 |
# File 'lib/yinx/note_meta.rb', line 42 def to_h @h = attr_methods.each_with_object({}) do |method, hash| hash[method] = send method end end |
#updated_at ⇒ Object
38 39 40 |
# File 'lib/yinx/note_meta.rb', line 38 def updated_at Time.at updated / 1000 end |