Class: Refinery::ThumbnailDimensions::Geometry

Inherits:
Object
  • Object
show all
Defined in:
images/app/models/refinery/thumbnail_dimensions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(geometry) ⇒ Geometry



82
83
84
85
86
87
88
89
90
# File 'images/app/models/refinery/thumbnail_dimensions.rb', line 82

def initialize(geometry)
  @geometry = if geometry.is_a?(Symbol) && Refinery::Images.user_image_sizes.keys.include?(geometry)
    Refinery::Images.user_image_sizes[geometry]
  else
    geometry.to_s
  end

  @width, @height = @geometry.split(%r{\#{1,2}|\+|>|!|x}im)[0..1].map(&:to_f)
end

Instance Attribute Details

#geometryObject (readonly)

Returns the value of attribute geometry



81
82
83
# File 'images/app/models/refinery/thumbnail_dimensions.rb', line 81

def geometry
  @geometry
end

#heightObject (readonly)

Returns the value of attribute height



81
82
83
# File 'images/app/models/refinery/thumbnail_dimensions.rb', line 81

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width



81
82
83
# File 'images/app/models/refinery/thumbnail_dimensions.rb', line 81

def width
  @width
end

Instance Method Details

#custom?Boolean



92
93
94
# File 'images/app/models/refinery/thumbnail_dimensions.rb', line 92

def custom?
  %r{\d+x\d+>} === geometry
end