Helper Class

class Helper

def self.get_random_string(length=3)

source= (“A”..”Z”).to_a + (0..9).to_a
key=””
length.times{ key += source[rand(source.size)].to_s }
return key

end

def self.get_random_alphabet(length=1)

source= (“A”..”Z”).to_a
key=””
length.times{ key += source[rand(source.size)].to_s }
return key

end

def self.generate_random_uk_postcode

postcode = “#{get_random_alphabet(length=1)}#{rand(15)} #{rand(9)}#{get_random_alphabet(2)}”
return postcode

end

def self.write_json_to_location(data,location)

File.open(“#{location}.json”,”w”) do |f|
f.write(JSON.pretty_generate(data))
end

end

end

Leave a Reply

Your email address will not be published. Required fields are marked *