Sha256: 8d69f182cd0096a087d04c7c9e91e0fa493a205206790f1dd7d0255b9118d8f7
Contents?: true
Size: 841 Bytes
Versions: 1
Compression:
Stored size: 841 Bytes
Contents
module Commands class Record def initialize(store) @store = store end def call(client_name, time_to_log, day_month = nil) if day_month raise "Day/month is an unrecognised format. Use `%d-%m` format" unless day_month =~ /\d\d-\d\d/ day = day_month.split("-").first month = day_month.split("-").last # parse day_month = [Time.now.year.to_s, month, day].join "-" else day_month = Time.now.strftime("%Y-%m-%d") end @store[client_name] = {} if @store[client_name].nil? client = @store[client_name] if client[day_month] client[day_month] << time_to_log.to_i else client[day_month] = [ time_to_log.to_i ] end @store.save! puts "Logged #{time_to_log} for #{client_name}" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
detom-0.0.1 | lib/detom/commands/record.rb |