Module: Standupguy::DataMethods
Overview
Generic methods for pulling data from standup.json
Instance Method Summary collapse
- #date_key(date = :today) ⇒ Object
- #filename ⇒ Object
- #load_data ⇒ Object
- #write_data(current_standup) ⇒ Object
Instance Method Details
#date_key(date = :today) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/Standupguy.rb', line 22 def date_key(date = :today) date = date == :today ? DateTime.now : DateTime.strptime(date, "%Y-%m-%d") date.strftime("%Y-%m-%d") rescue ArgumentError date = :today retry end |
#filename ⇒ Object
30 31 32 |
# File 'lib/Standupguy.rb', line 30 def filename File.join(Standupguy::Core::DATA_ROOT, "standup.json") end |
#load_data ⇒ Object
34 35 36 |
# File 'lib/Standupguy.rb', line 34 def load_data @current_standup = JSON.load(File.open(filename)) end |
#write_data(current_standup) ⇒ Object
38 39 40 41 42 |
# File 'lib/Standupguy.rb', line 38 def write_data(current_standup) File.open(filename, "w") do |f| f << JSON.dump(current_standup) end end |