Class: Burp::FileModel
- Inherits:
-
Object
- Object
- Burp::FileModel
- Defined in:
- app/models/burp/file_model.rb
Instance Attribute Summary collapse
-
#public_path ⇒ Object
Returns the value of attribute public_path.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(public_path) ⇒ FileModel
constructor
A new instance of FileModel.
- #mtime ⇒ Object
- #on_disk_path ⇒ Object
- #size ⇒ Object
- #to_param ⇒ Object
Constructor Details
#initialize(public_path) ⇒ FileModel
Returns a new instance of FileModel.
6 7 8 |
# File 'app/models/burp/file_model.rb', line 6 def initialize(public_path) self.public_path = public_path end |
Instance Attribute Details
#public_path ⇒ Object
Returns the value of attribute public_path.
4 5 6 |
# File 'app/models/burp/file_model.rb', line 4 def public_path @public_path end |
Class Method Details
.all ⇒ Object
10 11 12 13 14 |
# File 'app/models/burp/file_model.rb', line 10 def self.all @file_paths = Dir.glob("#{Burp.content_directory}uploads/*").select{|path| File.file?(path) } @file_paths = @file_paths.map {|path| path.gsub("#{Burp.content_directory}uploads/","/burp/files/") } @file_paths.map {|path| FileModel.new(path)}.sort.reverse end |
Instance Method Details
#<=>(other) ⇒ Object
32 33 34 |
# File 'app/models/burp/file_model.rb', line 32 def <=>(other) other.is_a?(FileModel) ? self.mtime <=> other.mtime : 0 end |
#eql?(other) ⇒ Boolean
36 37 38 |
# File 'app/models/burp/file_model.rb', line 36 def eql?(other) self.class == other.class && self.hash == other.hash end |
#hash ⇒ Object
40 41 42 |
# File 'app/models/burp/file_model.rb', line 40 def hash public_path.hash end |
#mtime ⇒ Object
24 25 26 |
# File 'app/models/burp/file_model.rb', line 24 def mtime @mtime_cache ||= File.mtime(on_disk_path) end |
#on_disk_path ⇒ Object
20 21 22 |
# File 'app/models/burp/file_model.rb', line 20 def on_disk_path public_path.gsub("/burp/files/","#{Burp.content_directory}uploads/") end |
#size ⇒ Object
28 29 30 |
# File 'app/models/burp/file_model.rb', line 28 def size @size_cache ||= File.size(on_disk_path) end |
#to_param ⇒ Object
16 17 18 |
# File 'app/models/burp/file_model.rb', line 16 def to_param public_path end |