Class: Uploadcare::Rails::Operations
- Inherits:
-
Object
- Object
- Uploadcare::Rails::Operations
- Defined in:
- lib/uploadcare/rails/operations.rb
Instance Method Summary collapse
- #format(options) ⇒ Object
-
#initialize(operations = nil) ⇒ Operations
constructor
A new instance of Operations.
- #inline(options) ⇒ Object
- #preview(options) ⇒ Object
- #progressive(options) ⇒ Object
- #quality(options) ⇒ Object
- #resize(options) ⇒ Object (also: #size)
- #to_s ⇒ Object
Constructor Details
#initialize(operations = nil) ⇒ Operations
Returns a new instance of Operations.
4 5 6 |
# File 'lib/uploadcare/rails/operations.rb', line 4 def initialize(operations = nil) @operations = operations end |
Instance Method Details
#format(options) ⇒ Object
22 23 24 25 |
# File 'lib/uploadcare/rails/operations.rb', line 22 def format() return unless %w(png jpeg).include?(.to_s) "format/#{ }" end |
#inline(options) ⇒ Object
52 53 54 |
# File 'lib/uploadcare/rails/operations.rb', line 52 def inline() end |
#preview(options) ⇒ Object
38 39 40 41 42 |
# File 'lib/uploadcare/rails/operations.rb', line 38 def preview() if option = [/^\d+x\d+$/] "preview/#{ option }" end end |
#progressive(options) ⇒ Object
27 28 29 30 |
# File 'lib/uploadcare/rails/operations.rb', line 27 def progressive() return unless %w(yes no).include?(.to_s) "progressive/#{ }" end |
#quality(options) ⇒ Object
32 33 34 35 36 |
# File 'lib/uploadcare/rails/operations.rb', line 32 def quality() = %w(normal better best lighter lightest) return unless .include?(.to_s) "quality/#{ }" end |
#resize(options) ⇒ Object Also known as: size
44 45 46 47 48 |
# File 'lib/uploadcare/rails/operations.rb', line 44 def resize() if option = [/^(\d+x\d+)$|^(\d+x)$|^(x\d+)$/] "resize/#{ option }" end end |
#to_s ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/uploadcare/rails/operations.rb', line 8 def to_s return '' unless @operations result = @operations.map do |operation, | next unless respond_to?(operation) send(operation, ) end ['-/', result.join('/-/'), '/']. join. gsub(%r{\/+}, '/'). to_s end |