Class: Pipl::Person

Inherits:
FieldsContainer show all
Defined in:
lib/pipl/containers.rb

Constant Summary

Constants inherited from FieldsContainer

FieldsContainer::CLASS_CONTAINER

Instance Attribute Summary collapse

Attributes inherited from FieldsContainer

#addresses, #dob, #educations, #emails, #ethnicities, #gender, #images, #jobs, #languages, #names, #origin_countries, #phones, #relationships, #tags, #urls, #user_ids, #usernames

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from FieldsContainer

#add_field, #add_fields, #address, #all_fields, #education, #email, #ethnicity, fields_from_hash, #fields_to_hash, #image, #job, #language, #name, #origin_country, #phone, #relationship, #url, #user_id, #username

Constructor Details

#initialize(params = {}) ⇒ Person

Returns a new instance of Person.



251
252
253
254
255
256
257
# File 'lib/pipl/containers.rb', line 251

def initialize(params={})
  super params
  @id = params[:id]
  @match = params[:match]
  @search_pointer = params[:search_pointer]
  @inferred = params[:inferred] || false
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



249
250
251
# File 'lib/pipl/containers.rb', line 249

def id
  @id
end

#inferredObject (readonly)

Returns the value of attribute inferred.



249
250
251
# File 'lib/pipl/containers.rb', line 249

def inferred
  @inferred
end

#matchObject (readonly)

Returns the value of attribute match.



249
250
251
# File 'lib/pipl/containers.rb', line 249

def match
  @match
end

#search_pointerObject (readonly)

Returns the value of attribute search_pointer.



249
250
251
# File 'lib/pipl/containers.rb', line 249

def search_pointer
  @search_pointer
end

Class Method Details

.from_hash(h) ⇒ Object



259
260
261
262
263
264
265
266
267
268
# File 'lib/pipl/containers.rb', line 259

def self.from_hash(h)
  params = {
      id: h[:@id],
      match: h[:@match],
      search_pointer: h[:@search_pointer],
      inferred: h[:@inferred],
  }
  params[:fields] = fields_from_hash(h)
  self.new(params)
end

Instance Method Details

#is_searchable?Boolean

Returns:

  • (Boolean)


277
278
279
280
281
282
283
284
285
286
# File 'lib/pipl/containers.rb', line 277

def is_searchable?
  not @search_pointer.nil? or
      @names.any? { |f| f.is_searchable? } or
      @emails.any? { |f| f.is_searchable? } or
      @phones.any? { |f| f.is_searchable? } or
      @usernames.any? { |f| f.is_searchable? } or
      @user_ids.any? { |f| f.is_searchable? } or
      @urls.any? { |f| f.is_searchable? } or
      @addresses.any? { |f| f.is_sole_searchable? }
end

#to_hashObject



270
271
272
273
274
275
# File 'lib/pipl/containers.rb', line 270

def to_hash
  h = {}
  h[:search_pointer] = @search_pointer if @search_pointer and not @search_pointer.empty?
  h.update(fields_to_hash)
  h
end

#unsearchable_fieldsObject



288
289
290
# File 'lib/pipl/containers.rb', line 288

def unsearchable_fields
  all_fields.reject { |f| f.is_searchable? }
end