Skip to content

Instantly share code, notes, and snippets.

@komagata
Created October 5, 2020 07:26
Show Gist options
  • Save komagata/829a223fc208da342574b939adf5a737 to your computer and use it in GitHub Desktop.
Save komagata/829a223fc208da342574b939adf5a737 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'optparse'
ARGV.each do |file_from_arg|
file = File.read(file_from_arg)
print file.count("\n").to_s.rjust(8)
word = File.open(file_from_arg).read.split(/\s+/).count
print word.to_s.rjust(8)
size = FileTest.size(file_from_arg)
print size.to_s.rjust(8)
filename = File.open(file_from_arg) {|f| f.path }
puts filename.to_s.rjust(10)
end
=begin
if ARGV == 0
puts "引数が指定されていません"
elsif ARGV == 1
puts file_line_count
puts file_word_count
puts file_size
puts filename
elsif ARGV => 2
end
=end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment