Sha256: fbffe332928c0f2cdc0c304897767a27b85f46c48f1648e5072505990cdec1e9
Contents?: true
Size: 838 Bytes
Versions: 3
Compression:
Stored size: 838 Bytes
Contents
module Artwork class Thumbnail include Comparable NAME_PATTERN = /^(\d+)x(\w*?)(_2x)?$/i.freeze attr :name attr :width attr :label def initialize(name) @name = name.to_s if match = @name.match(NAME_PATTERN) @width = match[1].to_i @label = match[2].to_s.gsub(/^_|_$/, '') @retina_flag = match[3] end end def compatible? not width.nil? end def retina? @retina_flag == '_2x' end def <=>(other_thumb) width <=> other_thumb.width end def eq(other) name == other.name and \ width == other.width and \ label == other.label and \ retina? == other.retina? end alias == eq def self.compatible?(name) name.to_s =~ NAME_PATTERN ? true : false end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
artwork-0.3.2 | lib/artwork/thumbnail.rb |
artwork-0.3.1 | lib/artwork/thumbnail.rb |
artwork-0.3.0 | lib/artwork/thumbnail.rb |