class Fake

Public Class Methods

new() click to toggle source
# File lib/fakename.rb, line 6
def initialize
  agent = Mechanize.new
  agent.get("https://fakena.me/")
  agent.page.link_with(:text => "Generate Fake Name").click
  puts agent.page.title
  @hash = Hash[*agent.page.search("td").map { |x| x.children.text }]
  inst_variable_set(@hash)
end

Public Instance Methods

city() click to toggle source
# File lib/fakename.rb, line 48
def city
  @city_state_zip.tr(',','').split[0]
end
dob_day() click to toggle source
# File lib/fakename.rb, line 40
def dob_day
  @date_of_birth.split("-")[2]
end
dob_month() click to toggle source
# File lib/fakename.rb, line 36
def dob_month
  @date_of_birth.split("-")[1]
end
dob_year() click to toggle source
# File lib/fakename.rb, line 32
def dob_year
  @date_of_birth.split("-")[0]
end
first_name() click to toggle source
# File lib/fakename.rb, line 24
def first_name
  @name.split.first
end
hashed_data() click to toggle source
# File lib/fakename.rb, line 72
def hashed_data
  @hash
end
inst_variable_set(hash) click to toggle source
# File lib/fakename.rb, line 15
def inst_variable_set hash
  vars = hash.map {|k, v| k.downcase.tr(' ','_').tr(',','').gsub(':','') }
  vals = hash.map {|k, v| v }
  vars.zip(vals).each do |var, val|
    self.class.__send__(:attr_accessor, "#{var}")
    self.__send__("#{var}=",val)
  end
end
last_name() click to toggle source
# File lib/fakename.rb, line 28
def last_name
  @name.split.last
end
phone_area_code() click to toggle source
# File lib/fakename.rb, line 60
def phone_area_code
  @phone_number.tr('()','').split[0]
end
phone_line_number() click to toggle source
# File lib/fakename.rb, line 68
def phone_line_number
  @phone_number.split[1].split('-')[1]
end
phone_prefix() click to toggle source
# File lib/fakename.rb, line 64
def phone_prefix
  @phone_number.split[1].split('-')[0]
end
reload() click to toggle source
# File lib/fakename.rb, line 76
def reload
  initialize
end
state() click to toggle source
# File lib/fakename.rb, line 52
def state
  @city_state_zip.tr(',','').split[1]
end
street_number() click to toggle source
# File lib/fakename.rb, line 44
def street_number
  @street_address.split[0]
end
zip() click to toggle source
# File lib/fakename.rb, line 56
def zip
  @city_state_zip.tr(',','').split[2]
end