Class: Pipl::Field
Direct Known Subclasses
Address, DOB, Education, Email, Ethnicity, Gender, Image, Job, Language, Name, OriginCountry, Phone, Tag, Url, Username
Instance Attribute Summary collapse
-
#inferred ⇒ Object
Returns the value of attribute inferred.
-
#valid_since ⇒ Object
Returns the value of attribute valid_since.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Field
constructor
A new instance of Field.
- #is_searchable? ⇒ Boolean
- #to_hash ⇒ Object
Methods included from Utils
alnum_chars, alpha_chars, date_to_str, is_valid_url?, str_to_date, titleize, to_utf8
Constructor Details
#initialize(params = {}) ⇒ Field
Returns a new instance of Field.
14 15 16 17 |
# File 'lib/pipl/fields.rb', line 14 def initialize(params={}) @valid_since = params[:valid_since] @inferred = params[:inferred] end |
Instance Attribute Details
#inferred ⇒ Object
Returns the value of attribute inferred.
12 13 14 |
# File 'lib/pipl/fields.rb', line 12 def inferred @inferred end |
#valid_since ⇒ Object
Returns the value of attribute valid_since.
12 13 14 |
# File 'lib/pipl/fields.rb', line 12 def valid_since @valid_since end |
Class Method Details
.base_params_from_hash(h) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/pipl/fields.rb', line 26 def self.base_params_from_hash(h) params = { inferred: h[:@inferred], type: h[:@type], display: h[:display] } params[:valid_since] = Date.strptime(h[:@valid_since], Pipl::DATE_FORMAT) if h.key? :@valid_since params[:date_range] = Pipl::DateRange.from_hash(h[:date_range]) if h.key? :date_range params end |
.extra_metadata ⇒ Object
37 38 39 |
# File 'lib/pipl/fields.rb', line 37 def self. [] end |
.from_hash(h) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/pipl/fields.rb', line 19 def self.from_hash(h) params = base_params_from_hash h .each { |p| params[p] = h["@#{p}".to_sym] } params = h.merge params self.new(params) end |
Instance Method Details
#is_searchable? ⇒ Boolean
45 46 47 |
# File 'lib/pipl/fields.rb', line 45 def is_searchable? true end |
#to_hash ⇒ Object
41 42 43 |
# File 'lib/pipl/fields.rb', line 41 def to_hash end |