Class: Hookalist::File
- Inherits:
-
Object
- Object
- Hookalist::File
- Defined in:
- lib/hookalist/file.rb
Instance Attribute Summary collapse
-
#commit_time ⇒ Object
readonly
Returns the value of attribute commit_time.
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
Instance Method Summary collapse
- #file_path ⇒ Object
-
#initialize(file_name, start_time, commit_time) ⇒ File
constructor
A new instance of File.
- #touch_command ⇒ Object
Constructor Details
#initialize(file_name, start_time, commit_time) ⇒ File
Returns a new instance of File.
5 6 7 8 9 |
# File 'lib/hookalist/file.rb', line 5 def initialize(file_name, start_time, commit_time) @file_name = file_name @start_time = start_time.clone @commit_time = commit_time.clone end |
Instance Attribute Details
#commit_time ⇒ Object (readonly)
Returns the value of attribute commit_time.
3 4 5 |
# File 'lib/hookalist/file.rb', line 3 def commit_time @commit_time end |
#file_name ⇒ Object (readonly)
Returns the value of attribute file_name.
3 4 5 |
# File 'lib/hookalist/file.rb', line 3 def file_name @file_name end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
3 4 5 |
# File 'lib/hookalist/file.rb', line 3 def start_time @start_time end |
Instance Method Details
#file_path ⇒ Object
11 12 13 |
# File 'lib/hookalist/file.rb', line 11 def file_path @file_path ||= Dir.pwd + "/#{file_name}" end |
#touch_command ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/hookalist/file.rb', line 15 def touch_command c_time = rand(start_time...commit_time) seconds = (Time.now - c_time).to_i command = "touch -d \"#{seconds} seconds ago\" #{file_path}" puts "#{command}" command end |