Class: Pipl::Gender

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

Instance Attribute Summary collapse

Attributes inherited from Field

#inferred, #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, is_valid_url?, str_to_date, titleize, to_utf8

Constructor Details

#initialize(params = {}) ⇒ Gender

Returns a new instance of Gender.

Raises:

  • (ArgumentError)


558
559
560
561
562
563
# File 'lib/pipl/fields.rb', line 558

def initialize(params={})
  super params
  raise ArgumentError.new("#{params[:content]} is not a valid gender") \
  unless %w(male female).include? params[:content]
  @content = params[:content]
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



556
557
558
# File 'lib/pipl/fields.rb', line 556

def content
  @content
end

Instance Method Details

#to_hashObject



569
570
571
# File 'lib/pipl/fields.rb', line 569

def to_hash
  {content: @content} if @content
end

#to_sObject



565
566
567
# File 'lib/pipl/fields.rb', line 565

def to_s
  Pipl::Utils.titleize @content if @content
end