Class: Yinx::NoteMeta

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#batchesObject

Returns the value of attribute batches.



4
5
6
# File 'lib/yinx_st/note_meta.rb', line 4

def batches
  @batches
end

#dump_atObject

Returns the value of attribute dump_at.



4
5
6
# File 'lib/yinx_st/note_meta.rb', line 4

def dump_at
  @dump_at
end

#dump_idObject

Returns the value of attribute dump_id.



4
5
6
# File 'lib/yinx_st/note_meta.rb', line 4

def dump_id
  @dump_id
end

Instance Method Details

#changed_tags?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/yinx_st/note_meta.rb', line 37

def changed_tags?
  prev_version and prev_version.tags.sort != self.tags.sort
end

#created_today?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/yinx_st/note_meta.rb', line 14

def created_today?
  created_at.between? (dump_at - 1.day), dump_at
end

#deleted_today?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/yinx_st/note_meta.rb', line 18

def deleted_today?
  batches.of_guid(guid).first == self and dump_id != batches.latest_id
end

#dump_dayObject



6
7
8
# File 'lib/yinx_st/note_meta.rb', line 6

def dump_day
  dump_at.strftime '%y/%m/%d %a'
end

#moved_book?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/yinx_st/note_meta.rb', line 33

def moved_book?
  prev_version and (prev_version.book != self.book or prev_version.stack != self.stack)
end

#prev_versionObject



29
30
31
# File 'lib/yinx_st/note_meta.rb', line 29

def prev_version
  @prev_version ||= batches.of_guid(guid).bsearch{|version| version.dump_id < self.dump_id}
end

#stack_bookObject



41
42
43
44
# File 'lib/yinx_st/note_meta.rb', line 41

def stack_book
  st = stack.nil? ? '' : "#{stack}/"
  "#{st}#{book}"
end

#stack_nameObject



46
47
48
# File 'lib/yinx_st/note_meta.rb', line 46

def stack_name
  stack ? stack : 'No Stack'
end

#statusObject



22
23
24
25
26
27
# File 'lib/yinx_st/note_meta.rb', line 22

def status
  return :created if created_today?
  return :updated if updated_today?
  return :deleted if deleted_today?
  :remained
end

#tags_countObject



50
51
52
# File 'lib/yinx_st/note_meta.rb', line 50

def tags_count
  tags.count
end

#updated_today?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/yinx_st/note_meta.rb', line 10

def updated_today?
  updated_at.between? (dump_at - 1.day), dump_at
end