Class: Saviour::ReadOnlyFile
- Inherits:
-
Object
- Object
- Saviour::ReadOnlyFile
- Defined in:
- lib/saviour/read_only_file.rb
Instance Attribute Summary collapse
-
#persisted_path ⇒ Object
readonly
Returns the value of attribute persisted_path.
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
Instance Method Summary collapse
- #==(another_file) ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(persisted_path, storage) ⇒ ReadOnlyFile
constructor
A new instance of ReadOnlyFile.
- #persisted? ⇒ Boolean
- #public_url ⇒ Object (also: #url)
- #read ⇒ Object
Constructor Details
#initialize(persisted_path, storage) ⇒ ReadOnlyFile
Returns a new instance of ReadOnlyFile.
5 6 7 8 |
# File 'lib/saviour/read_only_file.rb', line 5 def initialize(persisted_path, storage) @persisted_path = persisted_path @storage = storage end |
Instance Attribute Details
#persisted_path ⇒ Object (readonly)
Returns the value of attribute persisted_path.
3 4 5 |
# File 'lib/saviour/read_only_file.rb', line 3 def persisted_path @persisted_path end |
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
3 4 5 |
# File 'lib/saviour/read_only_file.rb', line 3 def storage @storage end |
Instance Method Details
#==(another_file) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/saviour/read_only_file.rb', line 25 def ==(another_file) return false unless another_file.is_a?(Saviour::File) || another_file.is_a?(ReadOnlyFile) return false unless another_file.persisted? another_file.persisted_path == persisted_path end |
#exists? ⇒ Boolean
10 11 12 |
# File 'lib/saviour/read_only_file.rb', line 10 def exists? persisted? && @storage.exists?(@persisted_path) end |
#persisted? ⇒ Boolean
32 33 34 |
# File 'lib/saviour/read_only_file.rb', line 32 def persisted? true end |
#public_url ⇒ Object Also known as: url
19 20 21 22 |
# File 'lib/saviour/read_only_file.rb', line 19 def public_url return nil unless persisted? @storage.public_url(@persisted_path) end |
#read ⇒ Object
14 15 16 17 |
# File 'lib/saviour/read_only_file.rb', line 14 def read return nil unless persisted? @storage.read(@persisted_path) end |