Skip to content

Commit

Permalink
Added secondary_address for suite and apartment numbers. New option f…
Browse files Browse the repository at this point in the history
…or street_address to determine whether to return the secondary address (defaults to false).
  • Loading branch information
stympy committed Jan 2, 2008
1 parent 741ea01 commit 87578bb
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions lib/faker/address.rb
Expand Up @@ -24,15 +24,19 @@ def street_name
].rand.call
end

def street_address
def street_address(include_secondary = false)
Faker.numerify([
Proc.new { '##### %s' % street_name },
Proc.new { '##### %s' % street_name },
Proc.new { '##### %s' % street_name },
Proc.new { '##### %s' % street_name },
Proc.new { '##### %s Apt. ###' % street_name },
Proc.new { '##### %s Suite ###' % street_name }
].rand.call)
'##### %s' % street_name,
'#### %s' % street_name,
'### %s' % street_name
].rand + (include_secondary ? ' ' + secondary_address : ''))
end

def secondary_address
Faker.numerify([
'Apt. ###',
'Suite ###'
].rand)
end

# UK Variants
Expand All @@ -46,9 +50,9 @@ def uk_country

def uk_postcode
Faker.bothify([
Proc.new { '??# #??' },
Proc.new { '??## #??' }
].rand.call).upcase
'??# #??',
'??## #??'
].rand).upcase
end
end
end
Expand Down

0 comments on commit 87578bb

Please sign in to comment.