Class: Sinicum::Imaging::ImageSizeConverter
- Inherits:
-
Object
- Object
- Sinicum::Imaging::ImageSizeConverter
- Defined in:
- lib/sinicum/imaging/image_size_converter.rb
Overview
Public: Calculates the size of an image based on the converter used to render the image.
Constant Summary collapse
- DEFAULT_WORKSPACE =
"dam"
Instance Method Summary collapse
- #height ⇒ Object
-
#initialize(image_or_jcr_path, converter_name, options = {}) ⇒ ImageSizeConverter
constructor
A new instance of ImageSizeConverter.
- #width ⇒ Object
Constructor Details
#initialize(image_or_jcr_path, converter_name, options = {}) ⇒ ImageSizeConverter
Returns a new instance of ImageSizeConverter.
8 9 10 11 12 13 14 15 16 |
# File 'lib/sinicum/imaging/image_size_converter.rb', line 8 def initialize(image_or_jcr_path, converter_name, = {}) if image_or_jcr_path.is_a?(String) workspace = [:workspace].presence || DEFAULT_WORKSPACE @image = Sinicum::Jcr::Node.find_by_path(workspace, image_or_jcr_path) elsif image_or_jcr_path.respond_to?(:width) && image_or_jcr_path.respond_to?(:height) @image = image_or_jcr_path end @converter_name = converter_name end |
Instance Method Details
#height ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/sinicum/imaging/image_size_converter.rb', line 29 def height unless defined?(@height) if converter.respond_to?(:converted_size) @height = converter.converted_size[1] else @height = @image.height end end @height end |
#width ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/sinicum/imaging/image_size_converter.rb', line 18 def width unless defined?(@width) if converter.respond_to?(:converted_size) @width = converter.converted_size[0] else @width = @image.width end end @width end |