Module: Pione::Util::LastTime

Defined in:
lib/pione/util/last-time.rb

Class Method Summary collapse

Class Method Details

.get(locations) ⇒ Object

Return last time of data locations. The criteria of last time is location's mtime and ctime.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/pione/util/last-time.rb', line 6

def self.get(locations)
  locations.inject(nil) do |last_time, location|
    mtime = location.mtime            # mtime should be supported
    ctime = location.ctime rescue nil # ctime may be not supported

    # get newer time
    this_time = [mtime, ctime].max

    # compare
    (last_time.nil? or last_time < this_time) ? this_time : last_time
  end
end