Class: Yinx::NoteMeta
- Inherits:
-
Object
- Object
- Yinx::NoteMeta
- Defined in:
- lib/yinx/note_meta.rb
Class Method Summary collapse
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.
18 19 20 21 |
# File 'lib/yinx/note_meta.rb', line 18 def initialize , note_store @meta = @store = note_store end |
Class Method Details
.from_h(hash) ⇒ Object
49 50 51 52 53 |
# File 'lib/yinx/note_meta.rb', line 49 def self.from_h hash raw = new nil, nil raw.marshal_load hash raw end |
Instance Method Details
#book ⇒ Object
27 28 29 |
# File 'lib/yinx/note_meta.rb', line 27 def book @book ||= @store.book_name notebookGuid end |
#created_at ⇒ Object
35 36 37 |
# File 'lib/yinx/note_meta.rb', line 35 def created_at Time.at created / 1000 end |
#marshal_dump ⇒ Object
55 56 57 |
# File 'lib/yinx/note_meta.rb', line 55 def marshal_dump to_h end |
#marshal_load(hash) ⇒ Object
59 60 61 62 63 |
# File 'lib/yinx/note_meta.rb', line 59 def marshal_load hash hash.each do |key, value| instance_variable_set "@#{key}", value end end |
#stack ⇒ Object
31 32 33 |
# File 'lib/yinx/note_meta.rb', line 31 def stack @stack = (instance_variable_defined? :@stack) ? @stack : @store.stack_name(notebookGuid) end |
#tags ⇒ Object
23 24 25 |
# File 'lib/yinx/note_meta.rb', line 23 def @tags ||= (tagGuids ? tagGuids.map{|id| @store.tag_name id} : []) end |
#to_h ⇒ Object
43 44 45 46 47 |
# File 'lib/yinx/note_meta.rb', line 43 def to_h @h = attr_methods.each_with_object({}) do |method, hash| hash[method] = send method end end |
#updated_at ⇒ Object
39 40 41 |
# File 'lib/yinx/note_meta.rb', line 39 def updated_at Time.at updated / 1000 end |