Class: Peephole::Logfile
- Inherits:
-
Object
- Object
- Peephole::Logfile
- Defined in:
- app/models/peephole/logfile.rb
Constant Summary collapse
- LOG_PATH =
Rails.root.join('log')
Instance Attribute Summary collapse
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#path ⇒ Object
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path) ⇒ Logfile
constructor
A new instance of Logfile.
- #loglines(page) ⇒ Object
- #size ⇒ Object
- #to_param ⇒ Object
- #updated_at ⇒ Object
Constructor Details
#initialize(path) ⇒ Logfile
Returns a new instance of Logfile.
26 27 28 29 |
# File 'app/models/peephole/logfile.rb', line 26 def initialize(path) self.path = path self.filename = File.basename(path) end |
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
3 4 5 |
# File 'app/models/peephole/logfile.rb', line 3 def filename @filename end |
#path ⇒ Object
Returns the value of attribute path.
3 4 5 |
# File 'app/models/peephole/logfile.rb', line 3 def path @path end |
Class Method Details
.all ⇒ Object
12 13 14 15 16 |
# File 'app/models/peephole/logfile.rb', line 12 def all glob.map do |path| Logfile.new(path) end end |
.find(filename) ⇒ Object
18 19 20 21 22 23 |
# File 'app/models/peephole/logfile.rb', line 18 def find(filename) path = glob.find do |path| File.basename(path) == filename end Logfile.new(path) end |
.glob ⇒ Object
8 9 10 |
# File 'app/models/peephole/logfile.rb', line 8 def glob Dir.glob(LOG_PATH.join("#{Rails.env}.log*")) end |
Instance Method Details
#loglines(page) ⇒ Object
35 36 37 |
# File 'app/models/peephole/logfile.rb', line 35 def loglines(page) Logline.where(path, page) end |
#size ⇒ Object
39 40 41 |
# File 'app/models/peephole/logfile.rb', line 39 def size File.size(path) / 1024 end |
#to_param ⇒ Object
31 32 33 |
# File 'app/models/peephole/logfile.rb', line 31 def to_param filename end |
#updated_at ⇒ Object
43 44 45 |
# File 'app/models/peephole/logfile.rb', line 43 def updated_at File.mtime(path) end |