Class: Bike::Img
Constant Summary collapse
- DEFAULT_META =
{ :width => 120, :height => 120, :options => ['png', 'jpg', 'jpeg', 'gif', 'tiff', 'bmp'], }
Instance Attribute Summary
Attributes inherited from Field
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
Methods inherited from File
#body, #meta_path, #meta_persistent_name, #meta_persistent_sd, #meta_tmp_path
Methods inherited from Field
#[], #[]=, #create, #default_action, #delete, #empty?, #find_ancestor, #get, h, #inspect, instance, #item, #load, #load_default, #meta_admins, #meta_client, #meta_folder, #meta_full_name, #meta_group, #meta_name, #meta_owner, #meta_owners, #meta_roles, #meta_sd, #meta_short_name, #pending?, #permit?, #post, #update, #val, #valid?, #workflow
Methods included from I18n
_, bindtextdomain, domain, domain=, find_msg, lang, lang=, merge_msg!, msg, n_, parse_msg, po_dir, po_dir=
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 |