Class: OAS::LogCollector::LogFile
- Inherits:
-
Object
- Object
- OAS::LogCollector::LogFile
- Defined in:
- lib/oas/log_collector/log_file.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
- #day ⇒ Object
-
#initialize(file_path) ⇒ LogFile
constructor
A new instance of LogFile.
- #month ⇒ Object
- #timestamp ⇒ Object
- #year ⇒ Object
Constructor Details
#initialize(file_path) ⇒ LogFile
Returns a new instance of LogFile.
7 8 9 10 |
# File 'lib/oas/log_collector/log_file.rb', line 7 def initialize(file_path) @name = File.basename(file_path) @time = Time.at(name[/.*\.log\.([0-9]+)\.?(.+)?$/, 1].to_i) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/oas/log_collector/log_file.rb', line 5 def name @name end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
5 6 7 |
# File 'lib/oas/log_collector/log_file.rb', line 5 def time @time end |
Instance Method Details
#day ⇒ Object
24 25 26 |
# File 'lib/oas/log_collector/log_file.rb', line 24 def day @time.strftime("%d") end |
#month ⇒ Object
20 21 22 |
# File 'lib/oas/log_collector/log_file.rb', line 20 def month @time.strftime("%m") end |
#timestamp ⇒ Object
12 13 14 |
# File 'lib/oas/log_collector/log_file.rb', line 12 def @time.to_i end |
#year ⇒ Object
16 17 18 |
# File 'lib/oas/log_collector/log_file.rb', line 16 def year @time.strftime("%Y") end |