Class: TBird::Namer
- Inherits:
-
Object
- Object
- TBird::Namer
- Defined in:
- lib/t_bird/namer.rb
Instance Attribute Summary collapse
-
#ext ⇒ Object
readonly
Returns the value of attribute ext.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize(original_filename, identifier = nil, token = nil) ⇒ Namer
constructor
A new instance of Namer.
- #new_name(version = 'original') ⇒ Object
Constructor Details
#initialize(original_filename, identifier = nil, token = nil) ⇒ Namer
10 11 12 13 14 |
# File 'lib/t_bird/namer.rb', line 10 def initialize(original_filename, identifier = nil, token = nil) @ext = Pathname.new(original_filename).extname @identifier = identifier || Digest::SHA1.hexdigest(original_filename) @token = token || SecureRandom.uuid end |
Instance Attribute Details
#ext ⇒ Object (readonly)
Returns the value of attribute ext.
9 10 11 |
# File 'lib/t_bird/namer.rb', line 9 def ext @ext end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
9 10 11 |
# File 'lib/t_bird/namer.rb', line 9 def identifier @identifier end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
9 10 11 |
# File 'lib/t_bird/namer.rb', line 9 def token @token end |
Instance Method Details
#new_name(version = 'original') ⇒ Object
16 17 18 |
# File 'lib/t_bird/namer.rb', line 16 def new_name(version = 'original') "#{identifier}/#{token}_#{version}#{ext}" end |