Class: Pipl::Education
Instance Attribute Summary collapse
-
#date_range ⇒ Object
Returns the value of attribute date_range.
-
#degree ⇒ Object
Returns the value of attribute degree.
-
#display ⇒ Object
Returns the value of attribute display.
-
#school ⇒ Object
Returns the value of attribute school.
Attributes inherited from Field
#current, #inferred, #last_seen, #valid_since
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Education
constructor
A new instance of Education.
- #to_hash ⇒ Object
- #to_s ⇒ Object
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_range ⇒ Object
Returns the value of attribute date_range.
358 359 360 |
# File 'lib/pipl/fields.rb', line 358 def date_range @date_range end |
#degree ⇒ Object
Returns the value of attribute degree.
358 359 360 |
# File 'lib/pipl/fields.rb', line 358 def degree @degree end |
#display ⇒ Object
Returns the value of attribute display.
358 359 360 |
# File 'lib/pipl/fields.rb', line 358 def display @display end |
#school ⇒ Object
Returns the value of attribute school.
358 359 360 |
# File 'lib/pipl/fields.rb', line 358 def school @school end |
Instance Method Details
#to_hash ⇒ Object
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_s ⇒ Object
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 |