Class: Pipl::Education

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

Instance Attribute Summary collapse

Attributes inherited from Field

#current, #inferred, #last_seen, #valid_since

Instance Method Summary collapse

Methods inherited from Field

base_params_from_hash, extra_metadata, from_hash, #is_searchable?

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 = {}) ⇒ Education

Returns a new instance of Education.



360
361
362
363
364
365
366
# File 'lib/pipl/fields.rb', line 360

def initialize(params={})
  super params
  @degree = params[:degree]
  @school = params[:school]
  @date_range = params[:date_range]
  @display = params[:display]
end

Instance Attribute Details

#date_rangeObject

Returns the value of attribute date_range.



358
359
360
# File 'lib/pipl/fields.rb', line 358

def date_range
  @date_range
end

#degreeObject

Returns the value of attribute degree.



358
359
360
# File 'lib/pipl/fields.rb', line 358

def degree
  @degree
end

#displayObject

Returns the value of attribute display.



358
359
360
# File 'lib/pipl/fields.rb', line 358

def display
  @display
end

#schoolObject

Returns the value of attribute school.



358
359
360
# File 'lib/pipl/fields.rb', line 358

def school
  @school
end

Instance Method Details

#to_hashObject



368
369
370
371
# File 'lib/pipl/fields.rb', line 368

def to_hash
  {degree: @degree, school: @school, date_range: @date_range ? @date_range.to_hash : nil}
      .reject { |_, value| value.nil? }
end

#to_sObject



373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# File 'lib/pipl/fields.rb', line 373

def to_s
  return @display if @display

  if @degree and @school
    s = @degree + ' from ' + @school
  else
    s = @degree || @school
  end

  if s and @date_range
    range = @date_range.years_range
    s += ' (%d-%d)' % [range[0], range[1]]
  end

  s ? Pipl::Utils.to_utf8(s) : ''
end