module FigMagic::StandardTranslation

Attributes

parent[R]

Public Instance Methods

catch_phrase() click to toggle source

return a random catch phrase

# File lib/fig_magic/standard_translation.rb, line 122
def catch_phrase
  Faker::Company.catch_phrase
end
Also aliased as: dm_catch_phrase
cell_phone() click to toggle source

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
Also aliased as: dm_cell_phone
characters(character_count = 255) click to toggle source

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
Also aliased as: dm_characters
city() click to toggle source

return a random city

# File lib/fig_magic/standard_translation.rb, line 73
def city
  Faker::Address.city
end
Also aliased as: dm_city
company_name() click to toggle source

return a random company name

# File lib/fig_magic/standard_translation.rb, line 114
def company_name
  Faker::Company.name
end
Also aliased as: dm_company_name
country() click to toggle source

return a random country

# File lib/fig_magic/standard_translation.rb, line 105
def country
  Faker::Address.country
end
Also aliased as: dm_country
credit_card_number() click to toggle source

return a credit card number

# File lib/fig_magic/standard_translation.rb, line 130
def credit_card_number
  Faker::Business.credit_card_number
end
Also aliased as: dm_credit_card_number
credit_card_type() click to toggle source

return a credit card type

# File lib/fig_magic/standard_translation.rb, line 138
def credit_card_type
  Faker::Business.credit_card_type
end
Also aliased as: dm_credit_card_type
dm_catch_phrase()
Alias for: catch_phrase
dm_cell_phone()
Alias for: cell_phone
dm_characters(character_count = 255)
Alias for: characters
dm_city()
Alias for: city
dm_company_name()
Alias for: company_name
dm_country()
Alias for: country
dm_credit_card_number()
Alias for: credit_card_number
dm_credit_card_type()
Alias for: credit_card_type
dm_domain_name()
Alias for: domain_name
dm_email_address(name=nil)
Alias for: email_address
dm_first_name()
Alias for: first_name
dm_full_name()
Alias for: full_name
dm_last_name()
Alias for: last_name
dm_mask(value)
Alias for: mask
dm_name_prefix()
Alias for: name_prefix
dm_name_suffix()
Alias for: name_suffix
dm_paragraphs(paragraph_count = 3)
Alias for: paragraphs
dm_phone_number()
Alias for: phone_number
dm_randomize(value)
Alias for: randomize
dm_secondary_address()
Alias for: secondary_address
dm_sentence(min_word_count = 4)
Alias for: sentence
dm_sentences(sentence_count = 3)
Alias for: sentences
dm_state()
Alias for: state
dm_state_abbr()
Alias for: state_abbr
dm_street_address(include_secondary=false)
Alias for: street_address
dm_title()
Alias for: title
dm_url()
Alias for: url
dm_user_name()
Alias for: user_name
dm_words(number = 3)
Alias for: words
dm_zip_code()
Alias for: zip_code
domain_name() click to toggle source

return a random domain name

# File lib/fig_magic/standard_translation.rb, line 194
def domain_name
  Faker::Internet.domain_name
end
Also aliased as: dm_domain_name
email_address(name=nil) click to toggle source

return a random email address

# File lib/fig_magic/standard_translation.rb, line 186
def email_address(name=nil)
  Faker::Internet.email(name)
end
Also aliased as: dm_email_address
first_name() click to toggle source

return a random first name

# File lib/fig_magic/standard_translation.rb, line 17
def first_name
  Faker::Name.first_name
end
Also aliased as: dm_first_name
full_name() click to toggle source

return a random name (first and last)

# File lib/fig_magic/standard_translation.rb, line 9
def full_name
  Faker::Name.name
end
Also aliased as: dm_full_name
last_name() click to toggle source

return a random last name

# File lib/fig_magic/standard_translation.rb, line 25
def last_name
  Faker::Name.last_name
end
Also aliased as: dm_last_name
mask(value) click to toggle source

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
Also aliased as: dm_mask
name_prefix() click to toggle source

return a random name prefix

# File lib/fig_magic/standard_translation.rb, line 33
def name_prefix
  Faker::Name.prefix
end
Also aliased as: dm_name_prefix
name_suffix() click to toggle source

return a random name suffix

# File lib/fig_magic/standard_translation.rb, line 41
def name_suffix
  Faker::Name.suffix
end
Also aliased as: dm_name_suffix
paragraphs(paragraph_count = 3) click to toggle source

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
Also aliased as: dm_paragraphs
phone_number() click to toggle source

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
Also aliased as: dm_phone_number
randomize(value) click to toggle source

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
Also aliased as: dm_randomize
secondary_address() click to toggle source

return a random secondary address

# File lib/fig_magic/standard_translation.rb, line 65
def secondary_address
  Faker::Address.secondary_address
end
Also aliased as: dm_secondary_address
sentence(min_word_count = 4) click to toggle source

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
Also aliased as: dm_sentence
sentences(sentence_count = 3) click to toggle source

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
Also aliased as: dm_sentences
sequential(value) click to toggle source

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
state() click to toggle source

return a random state

# File lib/fig_magic/standard_translation.rb, line 81
def state
  Faker::Address.state
end
Also aliased as: dm_state
state_abbr() click to toggle source

return a random state abbreviation

# File lib/fig_magic/standard_translation.rb, line 89
def state_abbr
  Faker::Address.state_abbr
end
Also aliased as: dm_state_abbr
street_address(include_secondary=false) click to toggle source

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
Also aliased as: dm_street_address
title() click to toggle source

return a random title

# File lib/fig_magic/standard_translation.rb, line 49
def title
  Faker::Name.title
end
Also aliased as: dm_title
url() click to toggle source

return a random url

# File lib/fig_magic/standard_translation.rb, line 202
def url
  Faker::Internet.url
end
Also aliased as: dm_url
user_name() click to toggle source

return a random user name

# File lib/fig_magic/standard_translation.rb, line 210
def user_name
  Faker::Internet.user_name
end
Also aliased as: dm_user_name
words(number = 3) click to toggle source

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
Also aliased as: dm_words
zip_code() click to toggle source

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
Also aliased as: dm_zip_code

Private Instance Methods

data_hash() click to toggle source
# File lib/fig_magic/standard_translation.rb, line 302
def data_hash
  $fig_magic_data_hash ||= {}
end
index_hash() click to toggle source
# 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
index_name(ary) click to toggle source
# File lib/fig_magic/standard_translation.rb, line 292
def index_name(ary)
  "#{ary[0]}#{ary[1]}_index".gsub(' ', '_').downcase
end
index_variable_for(ary) click to toggle source
# 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
process(value) click to toggle source
# File lib/fig_magic/standard_translation.rb, line 306
def process(value)
  eval value
end
remove_extension(phone) click to toggle source
# 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
set_index_variable(ary, value) click to toggle source
# File lib/fig_magic/standard_translation.rb, line 282
def set_index_variable(ary, value)
  index_hash[index_name(ary)] = value
end