Module: DataMagic::StandardTranslation

Included in:
DataMagic, Translation
Defined in:
lib/data_magic/standard_translation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent


4
5
6
# File 'lib/data_magic/standard_translation.rb', line 4

def parent
  @parent
end

Instance Method Details

#catch_phraseObject Also known as: dm_catch_phrase

return a random catch phrase


122
123
124
# File 'lib/data_magic/standard_translation.rb', line 122

def catch_phrase
  Faker::Company.catch_phrase
end

#cell_phoneObject Also known as: dm_cell_phone

return a random cell number


227
228
229
230
# File 'lib/data_magic/standard_translation.rb', line 227

def cell_phone
  value = Faker::PhoneNumber.cell_phone
  remove_extension(value)
end

#characters(character_count = 255) ⇒ Object Also known as: dm_characters

return random characters - default is 255 characters


178
179
180
# File 'lib/data_magic/standard_translation.rb', line 178

def characters(character_count = 255)
  Faker::Lorem.characters(character_count)
end

#cityObject Also known as: dm_city

return a random city


73
74
75
# File 'lib/data_magic/standard_translation.rb', line 73

def city
  Faker::Address.city
end

#company_nameObject Also known as: dm_company_name

return a random company name


114
115
116
# File 'lib/data_magic/standard_translation.rb', line 114

def company_name
  Faker::Company.name
end

#countryObject Also known as: dm_country

return a random country


105
106
107
# File 'lib/data_magic/standard_translation.rb', line 105

def country
  Faker::Address.country
end

#credit_card_numberObject Also known as: dm_credit_card_number

return a credit card number


130
131
132
# File 'lib/data_magic/standard_translation.rb', line 130

def credit_card_number
  Faker::Business.credit_card_number
end

#credit_card_typeObject Also known as: dm_credit_card_type

return a credit card type


138
139
140
# File 'lib/data_magic/standard_translation.rb', line 138

def credit_card_type
  Faker::Business.credit_card_type
end

#domain_nameObject Also known as: dm_domain_name

return a random domain name


194
195
196
# File 'lib/data_magic/standard_translation.rb', line 194

def domain_name
  Faker::Internet.domain_name
end

#email_address(name = nil) ⇒ Object Also known as: dm_email_address

return a random email address


186
187
188
# File 'lib/data_magic/standard_translation.rb', line 186

def email_address(name=nil)
  Faker::Internet.email(name)
end

#first_nameObject Also known as: dm_first_name

return a random first name


17
18
19
# File 'lib/data_magic/standard_translation.rb', line 17

def first_name
  Faker::Name.first_name
end

#full_nameObject Also known as: dm_full_name

return a random name (first and last)


9
10
11
# File 'lib/data_magic/standard_translation.rb', line 9

def full_name
  Faker::Name.name
end

#last_nameObject Also known as: dm_last_name

return a random last name


25
26
27
# File 'lib/data_magic/standard_translation.rb', line 25

def last_name
  Faker::Name.last_name
end

#mask(value) ⇒ Object Also known as: dm_mask

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


264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/data_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

#name_prefixObject Also known as: dm_name_prefix

return a random name prefix


33
34
35
# File 'lib/data_magic/standard_translation.rb', line 33

def name_prefix
  Faker::Name.prefix
end

#name_suffixObject Also known as: dm_name_suffix

return a random name suffix


41
42
43
# File 'lib/data_magic/standard_translation.rb', line 41

def name_suffix
  Faker::Name.suffix
end

#paragraphs(paragraph_count = 3) ⇒ Object Also known as: dm_paragraphs

return random paragraphs - default is 3 paragraphs


170
171
172
# File 'lib/data_magic/standard_translation.rb', line 170

def paragraphs(paragraph_count = 3)
  Faker::Lorem.paragraphs(paragraph_count).join('\n\n')
end

#phone_numberObject Also known as: dm_phone_number

return a random phone number


218
219
220
221
# File 'lib/data_magic/standard_translation.rb', line 218

def phone_number
  value = Faker::PhoneNumber.phone_number
  remove_extension(value)
end

#randomize(value) ⇒ Object Also known as: dm_randomize

return a random value from an array or range


236
237
238
239
240
241
242
# File 'lib/data_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

#secondary_addressObject Also known as: dm_secondary_address

return a random secondary address


65
66
67
# File 'lib/data_magic/standard_translation.rb', line 65

def secondary_address
  Faker::Address.secondary_address
end

#sentence(min_word_count = 4) ⇒ Object Also known as: dm_sentence

return a random sentence - default minimum word count is 4


154
155
156
# File 'lib/data_magic/standard_translation.rb', line 154

def sentence(min_word_count = 4)
  Faker::Lorem.sentence(min_word_count)
end

#sentences(sentence_count = 3) ⇒ Object Also known as: dm_sentences

return random sentences - default is 3 sentences


162
163
164
# File 'lib/data_magic/standard_translation.rb', line 162

def sentences(sentence_count = 3)
  Faker::Lorem.sentences(sentence_count).join(' ')
end

#sequential(value) ⇒ Object

return an element from the array. The first request will return the first element, the second request will return the second, and so forth.


250
251
252
253
254
255
256
# File 'lib/data_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

#stateObject Also known as: dm_state

return a random state


81
82
83
# File 'lib/data_magic/standard_translation.rb', line 81

def state
  Faker::Address.state
end

#state_abbrObject Also known as: dm_state_abbr

return a random state abbreviation


89
90
91
# File 'lib/data_magic/standard_translation.rb', line 89

def state_abbr
  Faker::Address.state_abbr
end

#street_address(include_secondary = false) ⇒ Object Also known as: dm_street_address

return a random street address


57
58
59
# File 'lib/data_magic/standard_translation.rb', line 57

def street_address(include_secondary=false)
  Faker::Address.street_address(include_secondary)
end

#titleObject Also known as: dm_title

return a random title


49
50
51
# File 'lib/data_magic/standard_translation.rb', line 49

def title
  Faker::Name.title
end

#urlObject Also known as: dm_url

return a random url


202
203
204
# File 'lib/data_magic/standard_translation.rb', line 202

def url
  Faker::Internet.url
end

#user_nameObject Also known as: dm_user_name

return a random user name


210
211
212
# File 'lib/data_magic/standard_translation.rb', line 210

def user_name
  Faker::Internet.user_name
end

#words(number = 3) ⇒ Object Also known as: dm_words

return random words - default is 3 words


146
147
148
# File 'lib/data_magic/standard_translation.rb', line 146

def words(number = 3)
  Faker::Lorem.words(number).join(' ')
end

#zip_codeObject Also known as: dm_zip_code

return a random 5 or 9 digit zip code


97
98
99
# File 'lib/data_magic/standard_translation.rb', line 97

def zip_code
  Faker::Address.zip
end