T
Thibaut Barrère
Hi
I'm practicing ruby everyday on small tools to learn more, could anyone
review what I've coded today ? This is a basic line of code counter
(pure ruby), any feedback welcome!
thanks !
Thibaut
def loc_file(file)
File.open(file).inject(0) { |loc,line| loc+1 }
end
def loc_by_extension(root,ext)
Dir[root+ext].inject(0) { |total,f| total + loc_file(f) }
end
["*.cs","*.cpp","*.h","*.resx"].each do |ext|
puts "#{loc_by_extension('c:/evolutionsyncfusion/**/',ext)} loc for
#{ext}"
end
I'm practicing ruby everyday on small tools to learn more, could anyone
review what I've coded today ? This is a basic line of code counter
(pure ruby), any feedback welcome!
thanks !
Thibaut
def loc_file(file)
File.open(file).inject(0) { |loc,line| loc+1 }
end
def loc_by_extension(root,ext)
Dir[root+ext].inject(0) { |total,f| total + loc_file(f) }
end
["*.cs","*.cpp","*.h","*.resx"].each do |ext|
puts "#{loc_by_extension('c:/evolutionsyncfusion/**/',ext)} loc for
#{ext}"
end