class RUser::Person
This class allows the creation of new users from the RandomUser.me API. @author Joshua Kendall
Constants
- KEYS
- NIDT
Attributes
@return [String] the user's cell phone number.
@return [String] the user's city.
@return [String] the user's birth date.
@return [String] the user's email.
@return [String] the user's first name.
@return [String] the user's gender, either male or female.
@return [String] the user's last name.
@return [String] the user's md5 hash of the user's salted password.
@return [String] the user's nationality
@return [String] the user's national Id number (SSN, PPS, HETU,, etc.).
@return [String] the user's national Id type (SSN, PPS, HETU, NINO, etc.).
@return [String] the user's password.
@return [String] the user's phone number.
@return [String] the user's zip code or postal code.
@return [String] the user's large profile photo url
@return [String] the user's medium profile photo url
@return [String] the user's thumbnail profile photo url
@return [String] the user's registration date.
@return [String] the user's password salt.
@return [String] the user's unique seed which allows future calls.
@return [String] the user's sha1 hash of the user's salted password.
@return [String] the user's sha256 hash of the user's salted password.
@return [String] the user's state.
@return [String] the user's street address.
@return [String] the user's title (Mr, Mrs, etc.).
@return [String] the user's username.
Public Class Methods
Creates a new person object
@param [Hash] data the data used to create the user @return [Person]
# File lib/ruser/person.rb, line 98 def initialize(data, nationality, seed) @nationality = nationality @seed = seed convert(data) end
Public Instance Methods
Converts a hash to instance variables
@param [Hash] data the data used to create the instance variables
# File lib/ruser/person.rb, line 107 def convert(data) data.each do |k, v| k = KEYS[k] if KEYS.include?(k) v = v.to_s if k.eql? 'zip' if NIDT.include?(k) instance_variable_set('@nidt', k) k = 'nidn' v = v.to_s end var_set(k, v) end end
Sets all instance variables
@param [String] k the key used to create the instance variables @param [String] v the value used to create the instance variables
# File lib/ruser/person.rb, line 126 def var_set(k, v) varget = proc { instance_variable_get("@#{k}") } varset = proc { |y| instance_variable_set("@#{k}", y) } v.is_a?(Hash) ? convert(v) : instance_variable_set("@#{k}", v) self.class.send(:define_method, k, varget) self.class.send(:define_method, "#{k}=", varset) end