Sha256: 5ee40ded0bf9b00c26ca3097b9bd43f50a7d04f61dc42a2d1c2397d6107ebaf4

Contents?: true

Size: 536 Bytes

Versions: 76

Compression:

Stored size: 536 Bytes

Contents

module Dragonfly
  # Convenience methods for setting basename and extension
  # Including class needs to define a 'name' accessor
  # which is assumed to hold a filename-style string
  module HasFilename
    
    def basename
      File.basename(name, '.*') if name
    end
    
    def basename=(basename)
      self.name = [basename, ext].compact.join('.')
    end

    def ext
      File.extname(name)[/\.(.*)/, 1] if name
    end
    
    def ext=(ext)
      self.name = [(basename || 'file'), ext].join('.')
    end
    
  end
end

Version data entries

76 entries across 76 versions & 2 rubygems

Version Path
dragonfly-1.4.1 lib/dragonfly/has_filename.rb
dragonfly-1.4.0 lib/dragonfly/has_filename.rb
dragonfly-1.3.0 lib/dragonfly/has_filename.rb
dragonfly-1.2.1 lib/dragonfly/has_filename.rb
dragonfly-1.2.0 lib/dragonfly/has_filename.rb
dragonfly-1.1.5 lib/dragonfly/has_filename.rb
dragonfly-1.1.4 lib/dragonfly/has_filename.rb
dragonfly-1.1.3 lib/dragonfly/has_filename.rb
dragonfly-1.1.2 lib/dragonfly/has_filename.rb
dragonfly-1.1.1 lib/dragonfly/has_filename.rb
dragonfly-1.1.0 lib/dragonfly/has_filename.rb
classiccms-0.7.5 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/has_filename.rb
classiccms-0.7.4 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/has_filename.rb
classiccms-0.7.3 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/has_filename.rb
dragonfly-1.0.12 lib/dragonfly/has_filename.rb
dragonfly-1.0.11 lib/dragonfly/has_filename.rb
dragonfly-1.0.10 lib/dragonfly/has_filename.rb
dragonfly-1.0.9 lib/dragonfly/has_filename.rb
dragonfly-1.0.8 lib/dragonfly/has_filename.rb
dragonfly-1.0.7 lib/dragonfly/has_filename.rb