Class: Nwsdk::Values
Constant Summary
Constants included from Helpers
Helpers::ATTACHMENT_FILENAME, Helpers::MULTIPART_BOUNDARY, Helpers::MULTIPART_END, Helpers::MULTIPART_PROLOGUE
Instance Attribute Summary collapse
-
#condition ⇒ Object
Returns the value of attribute condition.
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#flags ⇒ Object
Returns the value of attribute flags.
-
#key_name ⇒ Object
Returns the value of attribute key_name.
-
#limit ⇒ Object
Returns the value of attribute limit.
Instance Method Summary collapse
- #build_request ⇒ Object
-
#initialize(*args) ⇒ Values
constructor
A new instance of Values.
- #request ⇒ Object
Methods included from Helpers
#count_results, #decode_value, #each_multipart_response_entity, #format_timestamp, #get_boundary, #get_sessionids, #response_successful?
Constructor Details
#initialize(*args) ⇒ Values
Returns a new instance of Values.
7 8 9 10 11 12 |
# File 'lib/nwsdk/values.rb', line 7 def initialize(*args) Hash[*args].each {|k,v| self.send("%s="%k, v)} @flags ||= %w{ sort-total sessions order-descending } @limit ||= 10000 @key_name ||= 'service' end |
Instance Attribute Details
#condition ⇒ Object
Returns the value of attribute condition.
5 6 7 |
# File 'lib/nwsdk/values.rb', line 5 def condition @condition end |
#endpoint ⇒ Object
Returns the value of attribute endpoint.
5 6 7 |
# File 'lib/nwsdk/values.rb', line 5 def endpoint @endpoint end |
#flags ⇒ Object
Returns the value of attribute flags.
5 6 7 |
# File 'lib/nwsdk/values.rb', line 5 def flags @flags end |
#key_name ⇒ Object
Returns the value of attribute key_name.
5 6 7 |
# File 'lib/nwsdk/values.rb', line 5 def key_name @key_name end |
#limit ⇒ Object
Returns the value of attribute limit.
5 6 7 |
# File 'lib/nwsdk/values.rb', line 5 def limit @limit end |
Instance Method Details
#build_request ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/nwsdk/values.rb', line 14 def build_request endpoint.get_request( path: 'sdk', params: { msg: 'values', where: condition.format(use_time: false), time1: (condition.time1.utc), time2: (condition.time2.utc), size: limit, flags: flags.join(','), fieldName: key_name } ) end |
#request ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/nwsdk/values.rb', line 29 def request result=build_request.execute if response_successful?(result) count_results(JSON.parse(result)) else result end end |