Class: WebpageArchivist::Image

Inherits:
Sequel::Model
  • Object
show all
Includes:
WebpageElement
Defined in:
lib/webpage-archivist/models.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ElementWithContent

#save_content

Class Method Details

.compressObject



143
144
145
# File 'lib/webpage-archivist/models.rb', line 143

def self.compress
  false
end

.extention(uri, content_type) ⇒ Object



156
157
158
159
# File 'lib/webpage-archivist/models.rb', line 156

def self.extention uri, content_type
  extension = MIME::Types[content_type].andand[0].extensions.andand[0]
  extension ? ".#{extension}" : File.extname(Addressable::URI.parse(uri).normalize.path)[0...10]
end

Instance Method Details

#file_nameObject



152
153
154
# File 'lib/webpage-archivist/models.rb', line 152

def file_name
  "#{file_hash}#{extension}"
end

#validateObject



147
148
149
150
# File 'lib/webpage-archivist/models.rb', line 147

def validate
  super
  validates_max_length 10, :extension
end