forked from pollosp/saludos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpet-name.rb
executable file
·28 lines (22 loc) · 1.02 KB
/
pet-name.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require 'json'
def output(pet_names)
pet_names.each do |pet_name|
print sanitize(pet_name)
print "-" unless pet_name == pet_names.last
end
end
def sanitize(string)
string.tr(
"ÀÁÂÃÄÅàáâãäåĀāĂ㥹ÇçĆćĈĉĊċČčÐðĎďĐđÈÉÊËèéêëĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħÌÍÎÏìíîïĨĩĪīĬĭĮįİıĴĵĶķĸĹĺĻļĽľĿŀŁłÑñŃńŅņŇňʼnŊŋÒÓÔÕÖØòóôõöøŌōŎŏŐőŔŕŖŗŘřŚśŜŝŞşŠšſŢţŤťŦŧÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųŴŵÝýÿŶŷŸŹźŻżŽž",
"AAAAAAaaaaaaAaAaAaCcCcCcCcCcDdDdDdEEEEeeeeEeEeEeEeEeGgGgGgGgHhHhIIIIiiiiIiIiIiIiIiJjKkkLlLlLlLlLlNnNnNnNnnNnOOOOOOooooooOoOoOoRrRrRrSsSsSsSssTtTtTtUUUUuuuuUuUuUuUuUuUuWwYyyYyYZzZzZz"
)
end
DEFAULT_PET_NAME_COUNT = 2
pet_name_count = Integer(ARGV[0] || DEFAULT_PET_NAME_COUNT)
raw_greetings = File.read('saludos.json')
greetings = JSON.parse(raw_greetings)
pet_names = []
pet_name_count.times do
pet_names << greetings.delete_at(rand(greetings.length))
end
output(pet_names)