Class: Yinx::NoteMeta

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

Class Method Summary collapse

Instance Method Summary collapse

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

#bookObject



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

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

#created_atObject



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

def created_at
  Time.at created / 1000
end

#marshal_dumpObject



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

#stackObject



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

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

#tagsObject



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

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

#to_hObject



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_atObject



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

def updated_at
  Time.at updated / 1000
end