Class: ThumbnailSpec
- Inherits:
-
Object
- Object
- ThumbnailSpec
- Defined in:
- lib/httpthumbnailer/thumbnail_specs.rb
Defined Under Namespace
Classes: BadThubnailSpecError
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(method, width, height, format, options = {}) ⇒ ThumbnailSpec
constructor
A new instance of ThumbnailSpec.
- #to_s ⇒ Object
Constructor Details
#initialize(method, width, height, format, options = {}) ⇒ ThumbnailSpec
Returns a new instance of ThumbnailSpec.
46 47 48 49 50 51 52 |
# File 'lib/httpthumbnailer/thumbnail_specs.rb', line 46 def initialize(method, width, height, format, = {}) @method = method @width = cast_dimension(width) @height = cast_dimension(height) @format = (format == 'input' ? :input : format.upcase) @options = end |
Instance Attribute Details
#format ⇒ Object (readonly)
Returns the value of attribute format.
69 70 71 |
# File 'lib/httpthumbnailer/thumbnail_specs.rb', line 69 def format @format end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
69 70 71 |
# File 'lib/httpthumbnailer/thumbnail_specs.rb', line 69 def height @height end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
69 70 71 |
# File 'lib/httpthumbnailer/thumbnail_specs.rb', line 69 def method @method end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
69 70 71 |
# File 'lib/httpthumbnailer/thumbnail_specs.rb', line 69 def @options end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
69 70 71 |
# File 'lib/httpthumbnailer/thumbnail_specs.rb', line 69 def width @width end |
Class Method Details
.from_uri(spec) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/httpthumbnailer/thumbnail_specs.rb', line 54 def self.from_uri(spec) method, width, height, format, * = *spec.split(',') raise BadThubnailSpecError::MissingArgumentError.new(spec) unless method and width and height and format opts = {} .each do |option| key, value = option.split(':') raise BadThubnailSpecError::MissingOptionKeyOrValueError.new(option) unless key and value opts[key] = value end ThumbnailSpec.new(method, width, height, format, opts) end |
Instance Method Details
#to_s ⇒ Object
71 72 73 |
# File 'lib/httpthumbnailer/thumbnail_specs.rb', line 71 def to_s "#{method} #{width}x#{height} (#{format.downcase}) #{.inspect}" end |