Created
July 30, 2019 10:33
-
-
Save AK-10/12cb63d9f4d30f3a3ce09096d7a9eb15 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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