Class: TBird::Namer

Inherits:
Object
  • Object
show all
Defined in:
lib/t_bird/namer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#extObject (readonly)

Returns the value of attribute ext.



9
10
11
# File 'lib/t_bird/namer.rb', line 9

def ext
  @ext
end

#identifierObject (readonly)

Returns the value of attribute identifier.



9
10
11
# File 'lib/t_bird/namer.rb', line 9

def identifier
  @identifier
end

#tokenObject (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