Class: Runo::Img
- Inherits:
-
File
- Object
- File
- Runo::Img
- Defined in:
- lib/scalar/img.rb
Constant Summary collapse
- DEFAULT_META =
{ :width => 120, :height => 120, :options => ['png', 'jpg', 'jpeg', 'gif', 'tiff', 'bmp'], }
Class Method Summary collapse
Instance Method Summary collapse
- #commit(type = :temp) ⇒ Object
- #errors ⇒ Object
-
#initialize(meta = {}) ⇒ Img
constructor
A new instance of Img.
- #thumbnail ⇒ Object
Constructor Details
#initialize(meta = {}) ⇒ Img
Returns a new instance of Img.
23 24 25 26 |
# File 'lib/scalar/img.rb', line 23 def initialize( = {}) [:crop] = true if [:tokens] && [:tokens].include?('crop') super end |
Class Method Details
.quick_magick? ⇒ Boolean
19 20 21 |
# File 'lib/scalar/img.rb', line 19 def self.quick_magick? Object.const_defined? :QuickMagick end |
Instance Method Details
#commit(type = :temp) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/scalar/img.rb', line 45 def commit(type = :temp) super if type == :temp && @action == :delete @thumbnail = nil elsif type == :persistent && ps = my[:persistent_sd] case @action when :create, :update, nil ps.storage.store( "#{my[:persistent_name]}_small", @thumbnail, val['basename'][/\.([\w\.]+)$/, 1] || 'bin' ) if @thumbnail && valid? end end end |
#errors ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/scalar/img.rb', line 37 def errors if @error_thumbnail [_('wrong file type: should be %{types}') % {:types => my[:options].join('/')}] else super end end |