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 = nil, debug: false, date: Date.today, period: :daily, title: "My #{period.to_s.capitalize} Reflection") ⇒ DailyReflection

Returns a new instance of DailyReflection.



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

def initialize(s=nil, debug: false, date: Date.today, 
              period: :daily, 
               title: "My #{period.to_s.capitalize} Reflection" )

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

  check_period_entry()

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



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

def add_entry(s)

  check_period_entry()

  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



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

def create_day()
  create_date_entry(@date)
end

#create_monthObject



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

def create_month()
  create_date_entry(Date.civil(@date.year, @date.month, -1))
end

#create_weekObject



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

def create_week()

  d = @date
  d += 1 until d.wday == 0     

  create_date_entry(d)                                                   

end

#create_yearObject



57
58
59
# File 'lib/daily_reflection.rb', line 57

def create_year()
  create_date_entry(Date.new(@date.year+1,1,1)-1)
end

#find_date(d) ⇒ Object



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

def find_date(d)
  self.find d.strftime("%-d %b %Y")    
end

#todayObject



61
62
63
# File 'lib/daily_reflection.rb', line 61

def today()
  Entry.new(@dxsx.dx.all.first)
end