[Ruby] File Stats 04-03-2015, 03:09 AM
#1
As mentioned in my previous thread, I made a number of things on my flight. The second is a pretty compact file statistics tool. Good for an Essay written in some off-brand text editor or some code you want in-depth stats for.
There's not much I can see myself adding so I don't think I'll be updating this much.
Anyway, enjoy!
There's not much I can see myself adding so I don't think I'll be updating this much.
Anyway, enjoy!
Code:
#WordCount by Nightc||ed, ©2015
counta = 0
countb = 0
puts "Enter file name:"
file = gets.chomp
sspace = File.size("#{file}")
File.foreach("#{file}") { |line|
counta += line.scan(/[a-z0-9A-Z]+/).size
countb += line.scan(/[a-z0-9A-z ]/).size
}
system "cls"
puts "Stats for #{file}:
•contains #{counta} words
contains #{countb} standard characters
is #{sspace} Bytes in size"
sleepIt's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.
don't have much in the first place, who feel the new currents and ride them the farthest.
















![[+]](https://sinister.li/images/modern/collapse_collapsed.png)