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.
-
#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
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
Constructor Details
#initialize(params = {}) ⇒ Person
Returns a new instance of Person.
251 252 253 254 255 256 |
# File 'lib/pipl/containers.rb', line 251 def initialize(params={}) super params @id = params[:id] @match = params[:match] @search_pointer = params[:search_pointer] end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
249 250 251 |
# File 'lib/pipl/containers.rb', line 249 def id @id end |
#match ⇒ Object (readonly)
Returns the value of attribute match.
249 250 251 |
# File 'lib/pipl/containers.rb', line 249 def match @match end |
#search_pointer ⇒ Object (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
258 259 260 261 262 263 264 265 266 |
# File 'lib/pipl/containers.rb', line 258 def self.from_hash(h) params = { id: h[:@id], match: h[:@match], search_pointer: h[:@search_pointer], } params[:fields] = fields_from_hash(h) self.new(params) end |
Instance Method Details
#is_searchable? ⇒ Boolean
275 276 277 278 279 280 281 |
# File 'lib/pipl/containers.rb', line 275 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? } end |
#to_hash ⇒ Object
268 269 270 271 272 273 |
# File 'lib/pipl/containers.rb', line 268 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_fields ⇒ Object
283 284 285 |
# File 'lib/pipl/containers.rb', line 283 def unsearchable_fields all_fields.reject { |f| f.is_searchable? } end |