module FigMagic::StandardTranslation
Attributes
Public Instance Methods
return a random catch phrase
# File lib/fig_magic/standard_translation.rb, line 122 def catch_phrase Faker::Company.catch_phrase end
return a random cell number
# File lib/fig_magic/standard_translation.rb, line 227 def cell_phone value = Faker::PhoneNumber.cell_phone remove_extension(value) end
return random characters - default is 255 characters
# File lib/fig_magic/standard_translation.rb, line 178 def characters(character_count = 255) Faker::Lorem.characters(character_count) end
return a random city
# File lib/fig_magic/standard_translation.rb, line 73 def city Faker::Address.city end
return a random company name
# File lib/fig_magic/standard_translation.rb, line 114 def company_name Faker::Company.name end
return a random country
# File lib/fig_magic/standard_translation.rb, line 105 def country Faker::Address.country end
return a credit card number
# File lib/fig_magic/standard_translation.rb, line 130 def credit_card_number Faker::Business.credit_card_number end
return a credit card type
# File lib/fig_magic/standard_translation.rb, line 138 def credit_card_type Faker::Business.credit_card_type end
return a random domain name
# File lib/fig_magic/standard_translation.rb, line 194 def domain_name Faker::Internet.domain_name end
return a random email address
# File lib/fig_magic/standard_translation.rb, line 186 def email_address(name=nil) Faker::Internet.email(name) end
return a random first name
# File lib/fig_magic/standard_translation.rb, line 17 def first_name Faker::Name.first_name end
return a random name (first and last)
# File lib/fig_magic/standard_translation.rb, line 9 def full_name Faker::Name.name end
return a random last name
# File lib/fig_magic/standard_translation.rb, line 25 def last_name Faker::Name.last_name end
return a value based on a mast The # character will be replaced with a number The A character will be replaced with an upper case letter The a character will be replaced with a lower case letter
# File lib/fig_magic/standard_translation.rb, line 264 def mask(value) result = '' value.each_char do |ch| case ch when '#' then result += randomize(0..9).to_s when 'A' then result += ('A'..'Z').to_a[rand(26)] when 'a' then result += ('a'..'z').to_a[rand(26)] else result += ch end end result end
return a random name prefix
# File lib/fig_magic/standard_translation.rb, line 33 def name_prefix Faker::Name.prefix end
return a random name suffix
# File lib/fig_magic/standard_translation.rb, line 41 def name_suffix Faker::Name.suffix end
return random paragraphs - default is 3 paragraphs
# File lib/fig_magic/standard_translation.rb, line 170 def paragraphs(paragraph_count = 3) Faker::Lorem.paragraphs(paragraph_count).join('\n\n') end
return a random phone number
# File lib/fig_magic/standard_translation.rb, line 218 def phone_number value = Faker::PhoneNumber.phone_number remove_extension(value) end
return a random value from an array or range
# File lib/fig_magic/standard_translation.rb, line 236 def randomize(value) case value when Array then value[rand(value.size)] when Range then rand((value.last+1) - value.first) + value.first else value end end
return a random secondary address
# File lib/fig_magic/standard_translation.rb, line 65 def secondary_address Faker::Address.secondary_address end
return a random sentence - default minimum word count is 4
# File lib/fig_magic/standard_translation.rb, line 154 def sentence(min_word_count = 4) Faker::Lorem.sentence(min_word_count) end
return random sentences - default is 3 sentences
# File lib/fig_magic/standard_translation.rb, line 162 def sentences(sentence_count = 3) Faker::Lorem.sentences(sentence_count).join(' ') end
return an element from the array. The first request will return the first element, the second request will return the second, and so forth.
# File lib/fig_magic/standard_translation.rb, line 250 def sequential(value) index = index_variable_for(value) index = (index ? index + 1 : 0) index = 0 if index == value.length set_index_variable(value, index) value[index] end
return a random state
# File lib/fig_magic/standard_translation.rb, line 81 def state Faker::Address.state end
return a random state abbreviation
# File lib/fig_magic/standard_translation.rb, line 89 def state_abbr Faker::Address.state_abbr end
return a random street address
# File lib/fig_magic/standard_translation.rb, line 57 def street_address(include_secondary=false) Faker::Address.street_address(include_secondary) end
return a random title
# File lib/fig_magic/standard_translation.rb, line 49 def title Faker::Name.title end
return a random url
# File lib/fig_magic/standard_translation.rb, line 202 def url Faker::Internet.url end
return a random user name
# File lib/fig_magic/standard_translation.rb, line 210 def user_name Faker::Internet.user_name end
return random words - default is 3 words
# File lib/fig_magic/standard_translation.rb, line 146 def words(number = 3) Faker::Lorem.words(number).join(' ') end
return a random 5 or 9 digit zip code
# File lib/fig_magic/standard_translation.rb, line 97 def zip_code Faker::Address.zip end
Private Instance Methods
# File lib/fig_magic/standard_translation.rb, line 302 def data_hash $fig_magic_data_hash ||= {} end
# File lib/fig_magic/standard_translation.rb, line 296 def index_hash dh = data_hash[parent] data_hash[parent] = {} unless dh data_hash[parent] end
# File lib/fig_magic/standard_translation.rb, line 292 def index_name(ary) "#{ary[0]}#{ary[1]}_index".gsub(' ', '_').downcase end
# File lib/fig_magic/standard_translation.rb, line 286 def index_variable_for(ary) value = index_hash[index_name(ary)] index_hash[index_name(ary)] = -1 unless value index_hash[index_name(ary)] end
# File lib/fig_magic/standard_translation.rb, line 306 def process(value) eval value end
# File lib/fig_magic/standard_translation.rb, line 310 def remove_extension(phone) index = phone.index('x') phone = phone[0, (index-1)] if index phone end
# File lib/fig_magic/standard_translation.rb, line 282 def set_index_variable(ary, value) index_hash[index_name(ary)] = value end