class AccessGroup
Public Class Methods
time_in_atime(t, a)
click to toggle source
# File Entities/AccessGroups.rb, line 67 def self.time_in_atime(t, a) dow_raw, start_raw, stop_raw = a.split(';') {:di => 0, :lu => 1, :ma => 2, :me => 3, :je => 4, :ve => 5, :sa => 6}.each { |k, v| dow_raw.gsub!(/#{k}/, "#{v}") } dputs(4) { "dow_raw is #{dow_raw}" } dow = [] dow_raw.split(',').each { |d| if d =~ /(.)-(.)/ b, e = $1.to_i, $2.to_i if e < b e += 7 end (b..e).each { |i| dow.push(i % 7) } else dow.push d.to_i end } start_raw = start_raw.split(':') start = start_raw[0].to_i * 60 + start_raw[1].to_i stop_raw = stop_raw.split(':') stop = stop_raw[0].to_i * 60 + stop_raw[1].to_i if stop == 0 stop = 24 * 60 end time = t.hour * 60 + t.min time_dow = t.wday dputs(4) { "dow:#{dow.inspect} - start:#{start} - stop:#{stop}" } dputs(4) { "time: #{time} - time_dow:#{time_dow}" } # If we start in the evening and end in the morning... if start > stop and time < stop return (dow.index((time_dow + 6) % 7)) != nil end (dow.index(time_dow) and start <= time and time < stop) == true end
Public Instance Methods
time_in_atimes(t)
click to toggle source
# File Entities/AccessGroups.rb, line 106 def time_in_atimes(t) if access_times ret = false access_times.each { |a| ret = (ret or AccessGroup.time_in_atime(t, a)) } return ret else return true end end