How to generate whole positive numbers included in a range

Skip to first unread message


Jul 28, 2016, 5:06:24 PM7/28/16
to Ruby Faker
I would like to generate positive integers greater than 300 and smaller than 12000.
Considering Faker documentation, I still have to understand if the following usage can suit me:

Faker::Number.between(300, 12000)

There is a GitHub example which gives '7' as result if the range is between 1 and 10, and I do not understand if this means that the result is an integer.
I am also wondering if it is possible to combine/chain more methods and use for instance the following format:

Faker::Number.number(3, 5).between(300, 12000)

Conrad Taylor

Jul 28, 2016, 8:41:38 PM7/28/16
Hi, you should be able to do this by using the Ruby Standard Library:

# generate an array of even numbers > 300 but less than 1200
array = (301..11999).select(&:even?)

# generate an even number > 300 but less than 12000

Now, you have enough information generate your own between method.  If you have any questions, please do post here.  Well,  I must go and best of luck to you.

You received this message because you are subscribed to the Google Groups "Ruby Faker" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit


Think different and code well,


Reply all
Reply to author
0 new messages