Class: Pipl::Field

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/pipl/fields.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils

alnum_chars, alpha_chars, date_to_str, extract_rate_limits, is_valid_url?, str_to_date, titleize, to_utf8

Constructor Details

#initialize(params = {}) ⇒ Field

Returns a new instance of Field.



14
15
16
17
18
19
# File 'lib/pipl/fields.rb', line 14

def initialize(params={})
  @valid_since = params[:valid_since]
  @last_seen = params[:last_seen]
  @inferred = params[:inferred]
  @current = params[:current]
end

Instance Attribute Details

#currentObject

Returns the value of attribute current.



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

def current
  @current
end

#inferredObject

Returns the value of attribute inferred.



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

def inferred
  @inferred
end

#last_seenObject

Returns the value of attribute last_seen.



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

def last_seen
  @last_seen
end

#valid_sinceObject

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



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/pipl/fields.rb', line 28

def self.base_params_from_hash(h)
  params = {
      inferred: h[:@inferred],
      current: h[:@current],
      type: h[:@type],
      display: h[:display]
  }
  params[:valid_since] = Date.strptime(h[:@valid_since], Pipl::DATE_FORMAT) if h.key? :@valid_since
  params[:last_seen] = Date.strptime(h[:@last_seen], Pipl::DATE_FORMAT) if h.key? :@last_seen
  params[:date_range] = Pipl::DateRange.from_hash(h[:date_range]) if h.key? :date_range
  params
end

.extra_metadataObject



41
42
43
# File 'lib/pipl/fields.rb', line 41

def self.
  []
end

.from_hash(h) ⇒ Object



21
22
23
24
25
26
# File 'lib/pipl/fields.rb', line 21

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

Returns:

  • (Boolean)


49
50
51
# File 'lib/pipl/fields.rb', line 49

def is_searchable?
  true
end

#to_hashObject



45
46
47
# File 'lib/pipl/fields.rb', line 45

def to_hash

end