Class: Nwsdk::Condition
- Inherits:
-
Object
- Object
- Nwsdk::Condition
- Includes:
- Helpers
- Defined in:
- lib/nwsdk/condition.rb
Constant Summary
Constants included from Helpers
Helpers::ATTACHMENT_FILENAME, Helpers::MULTIPART_BOUNDARY, Helpers::MULTIPART_END, Helpers::MULTIPART_PROLOGUE
Instance Attribute Summary collapse
-
#end ⇒ Object
Returns the value of attribute end.
-
#id1 ⇒ Object
Returns the value of attribute id1.
-
#id2 ⇒ Object
Returns the value of attribute id2.
-
#span ⇒ Object
Returns the value of attribute span.
-
#start ⇒ Object
Returns the value of attribute start.
-
#tz_offset ⇒ Object
Returns the value of attribute tz_offset.
-
#where ⇒ Object
Returns the value of attribute where.
Instance Method Summary collapse
- #format(use_time: true) ⇒ Object
- #format_time_range ⇒ Object
-
#initialize(*args) ⇒ Condition
constructor
A new instance of Condition.
- #time1 ⇒ Object
-
#time1=(t) ⇒ Object
alias for #start.
- #time2 ⇒ Object
-
#time2=(t) ⇒ Object
alias for #end.
Methods included from Helpers
#count_results, #decode_value, #each_multipart_response_entity, #format_timestamp, #get_boundary, #get_sessionids, #response_successful?
Constructor Details
#initialize(*args) ⇒ Condition
Returns a new instance of Condition.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/nwsdk/condition.rb', line 6 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 |
Instance Attribute Details
#end ⇒ Object
Returns the value of attribute end.
4 5 6 |
# File 'lib/nwsdk/condition.rb', line 4 def end @end end |
#id1 ⇒ Object
Returns the value of attribute id1.
4 5 6 |
# File 'lib/nwsdk/condition.rb', line 4 def id1 @id1 end |
#id2 ⇒ Object
Returns the value of attribute id2.
4 5 6 |
# File 'lib/nwsdk/condition.rb', line 4 def id2 @id2 end |
#span ⇒ Object
Returns the value of attribute span.
4 5 6 |
# File 'lib/nwsdk/condition.rb', line 4 def span @span end |
#start ⇒ Object
Returns the value of attribute start.
4 5 6 |
# File 'lib/nwsdk/condition.rb', line 4 def start @start end |
#tz_offset ⇒ Object
Returns the value of attribute tz_offset.
4 5 6 |
# File 'lib/nwsdk/condition.rb', line 4 def tz_offset @tz_offset end |
#where ⇒ Object
Returns the value of attribute where.
4 5 6 |
# File 'lib/nwsdk/condition.rb', line 4 def where @where end |
Instance Method Details
#format(use_time: true) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/nwsdk/condition.rb', line 31 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 |
#format_time_range ⇒ Object
49 50 51 52 53 54 |
# File 'lib/nwsdk/condition.rb', line 49 def format_time_range sprintf("'%s'-'%s'", (@start), (@end) ) end |
#time1 ⇒ Object
62 63 64 |
# File 'lib/nwsdk/condition.rb', line 62 def time1 @start end |
#time1=(t) ⇒ Object
alias for #start
58 59 60 |
# File 'lib/nwsdk/condition.rb', line 58 def time1=(t) @start=t end |
#time2 ⇒ Object
72 73 74 |
# File 'lib/nwsdk/condition.rb', line 72 def time2 @end end |
#time2=(t) ⇒ Object
alias for #end
68 69 70 |
# File 'lib/nwsdk/condition.rb', line 68 def time2=(t) @end=t end |