Class: DailyReflection
- Inherits:
-
WikiMd
- Object
- WikiMd
- DailyReflection
- Defined in:
- lib/daily_reflection.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
Instance Method Summary collapse
- #add_entry(s) ⇒ Object
- #create_day ⇒ Object
- #find_today ⇒ Object
- #found_today? ⇒ Boolean
-
#initialize(s, debug: false, date: Date.today, title: 'My Daily Reflection') ⇒ DailyReflection
constructor
A new instance of DailyReflection.
- #today ⇒ Object
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
#date ⇒ Object
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..join(' ')) save_files() end |
#create_day ⇒ Object
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_today ⇒ Object
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
40 41 42 |
# File 'lib/daily_reflection.rb', line 40 def found_today?() self.find_today() end |
#today ⇒ Object
51 52 53 54 55 |
# File 'lib/daily_reflection.rb', line 51 def today() Entry.new(@dxsx.dx.all.first) end |