Class: Files
- Inherits:
-
Struct
- Object
- Struct
- Files
- Defined in:
- lib/file.rb
Overview
-
file_info: { command => file_name => file_info }
Instance Attribute Summary collapse
-
#commands ⇒ Object
Returns the value of attribute commands.
Instance Method Summary collapse
- #add(cmd, path) ⇒ Object
-
#modified(cmd, file) ⇒ Object
returns the modified date of the file, or nil if it is not yet known.
Instance Attribute Details
#commands ⇒ Object
Returns the value of attribute commands
10 11 12 |
# File 'lib/file.rb', line 10 def commands @commands end |
Instance Method Details
#add(cmd, path) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/file.rb', line 25 def add(cmd, path) files_info = commands[cmd.to_s] if files_info.nil? commands[cmd.to_s] = Hash.new files_info = commands[cmd.to_s] end files_info[path] = FileInfo.new( File.mtime(path).to_i # modified date as unix time stamp ) end |
#modified(cmd, file) ⇒ Object
returns the modified date of the file, or nil if it is not yet known
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/file.rb', line 12 def modified(cmd, file) files_info = commands[cmd.to_s] if files_info.nil? return nil end fi = files_info[file] if fi.nil? nil else fi.modified end end |