Class: Pipl::API::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/pipl/api/response.rb,
lib/pipl/api/response/age.rb,
lib/pipl/api/response/name.rb,
lib/pipl/api/response/gender.rb,
lib/pipl/api/response/person.rb,
lib/pipl/api/response/location.rb

Defined Under Namespace

Classes: Age, Gender, Location, Name, Person

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ Response

Returns a new instance of Response.



15
16
17
18
19
20
# File 'lib/pipl/api/response.rb', line 15

def initialize(raw)
  @data = MultiJson.load(raw)
  @status = @data.delete("@http_status_code")
  @warnings = @data.delete("warnings")
  @person = Person.new(@data)
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



10
11
12
# File 'lib/pipl/api/response.rb', line 10

def data
  @data
end

#personObject (readonly)

Returns the value of attribute person.



13
14
15
# File 'lib/pipl/api/response.rb', line 13

def person
  @person
end

#statusObject (readonly)

Returns the value of attribute status.



11
12
13
# File 'lib/pipl/api/response.rb', line 11

def status
  @status
end

#warningsObject (readonly)

Returns the value of attribute warnings.



12
13
14
# File 'lib/pipl/api/response.rb', line 12

def warnings
  @warnings
end

Instance Method Details

#ok?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/pipl/api/response.rb', line 22

def ok?
  status == 200
end