Class: Pipl::Person
- Inherits:
-
FieldsContainer
- Object
- FieldsContainer
- Pipl::Person
- Defined in:
- lib/pipl/containers.rb
Constant Summary
Constants inherited from FieldsContainer
FieldsContainer::CLASS_CONTAINER
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#inferred ⇒ Object
readonly
Returns the value of attribute inferred.
-
#match ⇒ Object
readonly
Returns the value of attribute match.
-
#search_pointer ⇒ Object
readonly
Returns the value of attribute search_pointer.
Attributes inherited from FieldsContainer
#addresses, #dob, #educations, #emails, #ethnicities, #gender, #images, #jobs, #languages, #names, #origin_countries, #phones, #relationships, #tags, #urls, #user_ids, #usernames, #vehicles
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Person
constructor
A new instance of Person.
- #is_searchable? ⇒ Boolean
- #to_hash ⇒ Object
- #unsearchable_fields ⇒ Object
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, #vehicle
Constructor Details
#initialize(params = {}) ⇒ Person
Returns a new instance of Person.
257 258 259 260 261 262 263 |
# File 'lib/pipl/containers.rb', line 257 def initialize(params={}) super params @id = params[:id] @match = params[:match] @search_pointer = params[:search_pointer] @inferred = params[:inferred] || false end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
255 256 257 |
# File 'lib/pipl/containers.rb', line 255 def id @id end |
#inferred ⇒ Object (readonly)
Returns the value of attribute inferred.
255 256 257 |
# File 'lib/pipl/containers.rb', line 255 def inferred @inferred end |
#match ⇒ Object (readonly)
Returns the value of attribute match.
255 256 257 |
# File 'lib/pipl/containers.rb', line 255 def match @match end |
#search_pointer ⇒ Object (readonly)
Returns the value of attribute search_pointer.
255 256 257 |
# File 'lib/pipl/containers.rb', line 255 def search_pointer @search_pointer end |
Class Method Details
.from_hash(h) ⇒ Object
265 266 267 268 269 270 271 272 273 274 |
# File 'lib/pipl/containers.rb', line 265 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
283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/pipl/containers.rb', line 283 def is_searchable? !@search_pointer.nil? || @names.any? { |f| f.is_searchable? } || @emails.any? { |f| f.is_searchable? } || @phones.any? { |f| f.is_searchable? } || @usernames.any? { |f| f.is_searchable? } || @user_ids.any? { |f| f.is_searchable? } || @urls.any? { |f| f.is_searchable? } || @addresses.any? { |f| f.is_sole_searchable? } || @vehicles.any? { |f| f.is_searchable? } end |
#to_hash ⇒ Object
276 277 278 279 280 281 |
# File 'lib/pipl/containers.rb', line 276 def to_hash h = {} h[:search_pointer] = @search_pointer if @search_pointer && ! @search_pointer.empty? h.update(fields_to_hash) h end |
#unsearchable_fields ⇒ Object
295 296 297 |
# File 'lib/pipl/containers.rb', line 295 def unsearchable_fields all_fields.reject { |f| f.is_searchable? } end |