Class: Filecount
- Inherits:
-
Object
- Object
- Filecount
- Defined in:
- lib/filecount.rb
Instance Attribute Summary collapse
-
#filecount ⇒ Object
readonly
Returns the value of attribute filecount.
Instance Method Summary collapse
-
#initialize ⇒ Filecount
constructor
A new instance of Filecount.
- #run(dir) ⇒ Object
Constructor Details
#initialize ⇒ Filecount
Returns a new instance of Filecount.
3 4 5 |
# File 'lib/filecount.rb', line 3 def initialize @filecount = 0 end |
Instance Attribute Details
#filecount ⇒ Object (readonly)
Returns the value of attribute filecount.
2 3 4 |
# File 'lib/filecount.rb', line 2 def filecount @filecount end |
Instance Method Details
#run(dir) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/filecount.rb', line 7 def run (dir) Dir.entries(dir).each do |file| if file != '.' && file != '..' then if File.directory?(file) fc = Filecount.new fc.run(file) @filecount += fc.filecount else @filecount += 1 end end end end |