Class: NoteMeta

Inherits:
Object
  • Object
show all
Defined in:
lib/yinx/note_meta.rb

Instance Method Summary collapse

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 meta, note_store
  @meta = meta
  @store = note_store
end

Instance Method Details

#bookObject



26
27
28
# File 'lib/yinx/note_meta.rb', line 26

def book
  @book ||= @store.book_name notebookGuid
end

#created_atObject



34
35
36
# File 'lib/yinx/note_meta.rb', line 34

def created_at
  Time.at created / 1000
end

#marshal_dumpObject



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

#stackObject



30
31
32
# File 'lib/yinx/note_meta.rb', line 30

def stack
  @stack = (instance_variable_defined? :@stack) ? @stack : @store.stack_name(notebookGuid)
end

#tagsObject



22
23
24
# File 'lib/yinx/note_meta.rb', line 22

def tags
  @tags ||= (tagGuids ? tagGuids.map{|id| @store.tag_name id} : [])
end

#to_hObject



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_atObject



38
39
40
# File 'lib/yinx/note_meta.rb', line 38

def updated_at
  Time.at updated / 1000
end