Class: ActiverecordHoarder::StorageKey
- Inherits:
-
Object
- Object
- ActiverecordHoarder::StorageKey
- Defined in:
- lib/activerecord_hoarder/storage_key.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(key_parts, file_extension) ⇒ StorageKey
constructor
A new instance of StorageKey.
- #to_s ⇒ Object
Constructor Details
#initialize(key_parts, file_extension) ⇒ StorageKey
Returns a new instance of StorageKey.
8 9 10 11 |
# File 'lib/activerecord_hoarder/storage_key.rb', line 8 def initialize(key_parts, file_extension) @key_parts = key_parts @file_extension = file_extension end |
Class Method Details
.from_date(date, file_extension = nil) ⇒ Object
3 4 5 6 |
# File 'lib/activerecord_hoarder/storage_key.rb', line 3 def self.from_date(date, file_extension = nil) key_parts = [date.year.to_s, date.month.to_s, date.iso8601] new(key_parts, file_extension) end |
Instance Method Details
#to_s ⇒ Object
13 14 15 16 |
# File 'lib/activerecord_hoarder/storage_key.rb', line 13 def to_s key_without_extension = File.join(@key_parts) @file_extension.present? ? key_without_extension + '.' + @file_extension.to_s : key_without_extension end |