class Mhc::Log

Public Class Methods

new(filename) click to toggle source
# File lib/mhc/sync/syncinfo.rb, line 11
def initialize(filename)
  @filename = filename
end

Public Instance Methods

add_entry(entry) click to toggle source
# File lib/mhc/sync/syncinfo.rb, line 15
def add_entry(entry)
  file = File.open(@filename, "a+")
  file.print "#{entry}\n"
  file.fsync if file.respond_to?("fsync")
  file.close
end
each_entry() { |mhc_log_entry| ... } click to toggle source
# File lib/mhc/sync/syncinfo.rb, line 22
def each_entry
  begin
    file = File.open(@filename)
    while line = file.gets
      yield(MhcLogEntry.new(line.chomp))
    end
    file.close
  rescue
  end
end
entries() click to toggle source
# File lib/mhc/sync/syncinfo.rb, line 33
def entries()
  arry = []
  each_entry{|e|
    arry << e
  }
  return arry
end
shrink_entries(user_id) click to toggle source
# File lib/mhc/sync/syncinfo.rb, line 41
def shrink_entries(user_id)
  hash = {}
  each_entry{|e|
    if e.status == 'S' and e.rec_id == user_id
      hash.clear
    else
      hash[e.rec_id] = e
    end
  }
  return hash.values
end