Skip to content

Instantly share code, notes, and snippets.

@AK-10
Created July 30, 2019 10:33
Show Gist options
  • Save AK-10/12cb63d9f4d30f3a3ce09096d7a9eb15 to your computer and use it in GitHub Desktop.
Save AK-10/12cb63d9f4d30f3a3ce09096d7a9eb15 to your computer and use it in GitHub Desktop.
# ARGV[0] : filepath
# ARGV[1] : kind (account | friends)
if ARGV.size < 2
puts "Error: argument num is not enough"
exit
end
path = ARGV[0]
kind = ARGV[1]
intros = "Hello, I'm Saburo.\n"
case kind
when "account"
File.open(path) do |f|
account_num = f.read
intros += "my account num is #{account_num}"
end
puts intros
when "friends"
intros += "my friends are\n"
File.open(path) do |f|
friends = f.read
intros += friends
end
puts intros
else
puts "Error: invalid kind."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment