Class: Jrn::Day
- Inherits:
-
Struct
- Object
- Struct
- Jrn::Day
- Defined in:
- lib/jrn/day.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
Instance Method Summary collapse
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date
5 6 7 |
# File 'lib/jrn/day.rb', line 5 def date @date end |
Instance Method Details
#start ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/jrn/day.rb', line 6 def start user_dir = Etc.getpwuid.dir jrn_dir = "#{user_dir}/.jrn/" day_file = "#{jrn_dir}/#{date}.md" is_new_day = !File.exist?(day_file) if is_new_day # Start new day from template File.open(day_file, 'w') do |file| file << "####{date}###\n" file << "\n" file << "* #{Time.now.strftime("%I:%M%p")}\n" file << "\s" end else # Start new line prompt if needed lines = File.read(day_file).split if lines.last != "\s" File.open(day_file, 'a') do |file| file << "\n" file << "* #{Time.now.strftime("%I:%M%p")}\n" file << "\s" end end end system("/usr/local/bin/vim \"+ normal G$\" +startinsert #{day_file}") # Backup here end |