class Raykit::Log
Public Class Methods
new(filename)
click to toggle source
# File lib/raykit/log.rb, line 5 def initialize(filename) @filename=filename dir=File.dirname(@filename) FileUtils.mkdir_p(dir) if(!Dir.exist?(dir)) if(File.exist?(@filename)) begin data=JSON.parse(File.read(filename)) data.each{|k,v| self[k] = v } rescue end end end
Public Instance Methods
get_command_time(command)
click to toggle source
# File lib/raykit/log.rb, line 33 def get_command_time(command) if(self.has_key?("command_times")) command_times = self["command_times"] if(command_times.has_key?(command)) return DateTime.parse(command_times[command]) end end nil end
save()
click to toggle source
# File lib/raykit/log.rb, line 20 def save File.open(@filename, 'w') {|f| f.write(JSON.generate(self)) } end
update_command_time(command,timestamp)
click to toggle source
# File lib/raykit/log.rb, line 24 def update_command_time(command,timestamp) command_times = Hash.new() command_times = self["command_times"] if(self.has_key?("command_times")) command_times.delete(command) if(command_times.has_key?(command)) command_times[command] = timestamp.iso8601() self["command_times"] = command_times save end