module Standupguy::DataMethods

Generic methods for pulling data from standup.json

Public Instance Methods

date_key(date = :today) click to toggle source
# 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() click to toggle source
# File lib/Standupguy.rb, line 30
def filename
  File.join(Standupguy::Core::DATA_ROOT, "standup.json")
end
load_data() click to toggle source
# File lib/Standupguy.rb, line 34
def load_data
  @current_standup = JSON.load(File.open(filename))
end
write_data(current_standup) click to toggle source
# File lib/Standupguy.rb, line 38
def write_data(current_standup)
  File.open(filename, "w") do |f|
    f << JSON.dump(current_standup)
  end
end