Class: Adrift::Pattern::Tags::Basename

Inherits:
Object
  • Object
show all
Defined in:
lib/adrift/pattern.rb

Overview

Pattern’s tag that allows to generally express the Attachment’s file base name.

Instance Method Summary collapse

Instance Method Details

#labelObject

Portion of Pattern#string that will be replaced.



156
157
158
# File 'lib/adrift/pattern.rb', line 156

def label
  ':basename'
end

#specialize(options = {}) ⇒ Object

Attachment’s file base name. Expects options to include the Attachment (:attachment key).



162
163
164
165
# File 'lib/adrift/pattern.rb', line 162

def specialize(options={})
  filename = options[:attachment].filename.to_s
  filename.sub(File.extname(filename), '')
end