Class: OAS::LogCollector::LogFile

Inherits:
Object
  • Object
show all
Defined in:
lib/oas/log_collector/log_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/oas/log_collector/log_file.rb', line 5

def name
  @name
end

#timeObject (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

#dayObject



24
25
26
# File 'lib/oas/log_collector/log_file.rb', line 24

def day
  @time.strftime("%d")
end

#monthObject



20
21
22
# File 'lib/oas/log_collector/log_file.rb', line 20

def month
  @time.strftime("%m")
end

#timestampObject



12
13
14
# File 'lib/oas/log_collector/log_file.rb', line 12

def timestamp
  @time.to_i
end

#yearObject



16
17
18
# File 'lib/oas/log_collector/log_file.rb', line 16

def year
  @time.strftime("%Y")
end