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 (also: #found_today)
-
#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.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/daily_reflection.rb', line 12 def initialize(s, debug: false, date: Date.today, title: 'My Daily Reflection') @date = date super(s, order: 'descending', debug: debug, title: title) # if the section for today doesn't exist create it create_day() unless found_today() end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
10 11 12 |
# File 'lib/daily_reflection.rb', line 10 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) create_day() unless found_today() rx = @dxsx.dx.all.first lines = rx.x.lines lines.insert -3, s + "\n" rx.x = lines.join end |
#create_day ⇒ Object
41 42 43 44 45 46 |
# File 'lib/daily_reflection.rb', line 41 def create_day() date = @date.strftime("%-d %b %Y") self.create_section "# %s\n\n\n+ %s" % [date, @date.year] end |
#find_today ⇒ Object Also known as: found_today
35 36 37 |
# File 'lib/daily_reflection.rb', line 35 def find_today() self.find @date.strftime("%-d %b %Y") end |
#today ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/daily_reflection.rb', line 48 def today() rx = @dxsx.dx.all.first def rx.body() x.lines[1..-2].join.strip end def rx.body=(s) text_entry = "%s\n\n%s\n\n%s" % [self.heading, s, self.] self.x = text_entry end def rx.() x.lines.last.chomp end def rx.(s) a = x.lines a[-1] = s self.x = a.join end def rx.heading() x.lines.first.chomp end def rx.() [1..-1].strip.split end rx end |