Class: RangeResponse

Inherits:
Struct show all
Defined in:
lib/dto/search/range_response.rb

Overview

Class RangeResponse represents server response on range Search API request. Server response is sent to from_array method which creates objects with attribute ranges accessible via getter:

response = RangeResponse.from_array(...)
response.ranges     # => Array

Defined Under Namespace

Classes: Range

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Struct

from_hash

Instance Attribute Details

#rangesObject

Returns the value of attribute ranges

Returns:

  • (Object)

    the current value of ranges



8
9
10
# File 'lib/dto/search/range_response.rb', line 8

def ranges
  @ranges
end

Class Method Details

.from_array(json) ⇒ Object

Method from_array creates RangeResponse object with a set of Range objects.



23
24
25
# File 'lib/dto/search/range_response.rb', line 23

def self.from_array(json)
  self.from_hash(:ranges => json.collect { |key, value| Range.from_hash( :field => key, :max => value["max"], :min => value["min"])})
end