Class: DailyReflection

Inherits:
WikiMd
  • Object
show all
Defined in:
lib/daily_reflection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(s, debug: false, date: Date.today, title: 'My Daily Reflection') ⇒ DailyReflection

Returns a new instance of DailyReflection.



13
14
15
16
17
18
19
20
21
# File 'lib/daily_reflection.rb', line 13

def initialize(s, debug: false, date: Date.today, 
              title: 'My Daily Reflection')

  @date = date
  super(s, order: 'descending', debug: debug, title: title)

  create_day() unless found_today?

end

Instance Attribute Details

#dateObject

Returns the value of attribute date.



11
12
13
# File 'lib/daily_reflection.rb', line 11

def date
  @date
end

Instance Method Details

#add_entry(s) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/daily_reflection.rb', line 23

def add_entry(s)

  create_day() unless found_today?

  e = Entry.new(@dxsx.dx.all.first)
  e.body = e.body + "\n" + s
  update_index(@dx.all.first, e.tags.join(' '))
  save_files()

end

#create_dayObject



44
45
46
47
48
49
# File 'lib/daily_reflection.rb', line 44

def create_day()

  date = @date.strftime("%-d %b %Y")
  self.create_section "# %s\n\n\n+ %s" % [date, @date.year]

end

#find_todayObject



34
35
36
37
38
# File 'lib/daily_reflection.rb', line 34

def find_today()
  r = self.find @date.strftime("%-d %b %Y")
  puts ('r: ' + r.inspect).debug if @debug
  r
end

#found_today?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/daily_reflection.rb', line 40

def found_today?()
  self.find_today()
end

#todayObject



51
52
53
54
55
# File 'lib/daily_reflection.rb', line 51

def today()

  Entry.new(@dxsx.dx.all.first)

end