Sha256: b15a92735c435aaef15b3114f2b035dae34ce1b0fd4e23a5aef78e9caaded9e2
Contents?: true
Size: 1.34 KB
Versions: 3
Compression:
Stored size: 1.34 KB
Contents
module Nwsdk class Condition include Helpers attr_accessor :where, :start, :end, :span, :id1, :id2, :tz_offset def initialize(*args) Hash[*args].each {|k,v| self.send("%s="%k, v)} init = Time.new # TODO: this is hella ugly, mane if @end.nil? @span ||= 3600 if @start.nil? @end=init @start=@end - @span else @end = @start + @span end else if @start.nil? @span ||= 3600 @start = @end - @span else @span = @end - @start end end @tz_offset = @start.gmtoff end def format(use_time: true) formatted_where=case where when nil "" else sprintf('(%s)',where) end if use_time if formatted_where=="" sprintf('time=%s', format_time_range) else sprintf('%s&&time=%s',formatted_where,format_time_range) end else formatted_where end end def format_time_range sprintf("'%s'-'%s'", format_timestamp(@start), format_timestamp(@end) ) end # alias for #start def time1=(t) @start=t end def time1 @start end # alias for #end def time2=(t) @end=t end def time2 @end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
nwsdk-1.2.0 | lib/nwsdk/condition.rb |
nwsdk-1.1.7 | lib/nwsdk/condition.rb |
nwsdk-1.1.3 | lib/nwsdk/condition.rb |