Class: Factual::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/factual.rb

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ Response

Returns a new instance of Response.



345
346
347
# File 'lib/factual.rb', line 345

def initialize(obj)
  @obj = obj
end

Instance Method Details

#[](*keys) ⇒ Object



349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
# File 'lib/factual.rb', line 349

def [](*keys)
  begin
    ret = @obj
    keys.each do |key|
      ret = ret[key]
    end

    if ret.is_a?(Hash)
      return Response.new(ret)
    else
      return ret
    end
  rescue Exception => e
    Factual::ResponseError.new("Unexpected API response")
  end
end