class Tlog::Entity::Entry
Attributes
hex[RW]
path[RW]
Public Class Methods
new(path, hex)
click to toggle source
# File lib/tlog/entity/entry.rb, line 7 def initialize(path, hex) @path = path @hex = hex end
Public Instance Methods
create(parent, current)
click to toggle source
# File lib/tlog/entity/entry.rb, line 16 def create(parent, current) FileUtils.mkdir_p(path) time_log = current[:start_time].to_s + " " + Time.now.to_s write_file(parent_path, parent) write_file(time_path, time_log.strip) write_file(description_path, current[:description]) #write_file(owner_path, current[:owner]) end
description()
click to toggle source
# File lib/tlog/entity/entry.rb, line 47 def description read_file(description_path) end
length()
click to toggle source
# File lib/tlog/entity/entry.rb, line 12 def length time_difference if time[:start] && time[:end] end
parent_hex()
click to toggle source
# File lib/tlog/entity/entry.rb, line 25 def parent_hex read_file(parent_path) end
time()
click to toggle source
# File lib/tlog/entity/entry.rb, line 29 def time time_hash = {} start_time_string = "" end_time_string = "" time_contents = read_file(time_path) return time_hash unless time_contents split_contents = time_contents.split(" ", 6) for i in 0..2 start_time_string += split_contents[i] + " " end for i in 3..5 end_time_string += split_contents[i] + " " end time_hash[:start] = Time.parse(start_time_string) time_hash[:end] = Time.parse(end_time_string) return time_hash end
Private Instance Methods
description_path()
click to toggle source
# File lib/tlog/entity/entry.rb, line 78 def description_path File.join(@path, 'DESCRIPTION') end
parent_path()
click to toggle source
# File lib/tlog/entity/entry.rb, line 70 def parent_path File.join(@path, 'PARENT') end
read_file(path)
click to toggle source
# File lib/tlog/entity/entry.rb, line 57 def read_file(path) if File.exists?(path) contents = File.read(path) contents.strip end end
time_difference()
click to toggle source
# File lib/tlog/entity/entry.rb, line 64 def time_difference time_hash = time difference = time_hash[:end] - time_hash[:start] difference.to_i end
time_path()
click to toggle source
# File lib/tlog/entity/entry.rb, line 74 def time_path File.join(@path, 'TIME') end
write_file(path, content)
click to toggle source
# File lib/tlog/entity/entry.rb, line 53 def write_file(path, content) File.open(path, 'w'){ |f| f.write(content)} end