class Library

Attributes

column_name[RW]

Public Instance Methods

check(column_name, type, limit) click to toggle source
# File lib/library.rb, line 5
def check(column_name, type, limit)
  @column_name = column_name
  call = case
         when type == :string then :name
         when type == :integer then :int
         when type == :datetime then :date
         else :name
         end
  self.send(call)
end
date() click to toggle source
# File lib/library.rb, line 29
def date
  num = Random.new.rand(1..10)
  "{ #{num}.days.ago }"
end
int() click to toggle source
# File lib/library.rb, line 34
def int
  if @column_name.include?('zip') 
    "'#{Faker::Address.zip_code}'"
  else
    Random.new.rand(0..1000)
  end
end
name() click to toggle source
# File lib/library.rb, line 16
def name
  case
  when @column_name.include?('name') then "'#{Faker::Name.name}'"
  when @column_name.include?('mail') then "'#{Faker::Internet.email}'"
  when @column_name.include?('address') then "'#{Faker::Address.street_address}'"
  when @column_name.include?('city') then "'#{Faker::Address.city}'"
  when @column_name.include?('state') then "'#{Faker::Address.state_abbr}'"
  when @column_name.include?('zip') then "'#{Faker::Address.zip_code}'"
  else "'#{Faker::Company.catch_phrase}'"
  end
  
end