Class: Thingfish::Processor::Image::MagickOperations

Inherits:
Object
  • Object
show all
Defined in:
lib/thingfish/processor/image.rb

Overview

A struct that can represent the support in the installed ImageMagick for common operations. See Magick.formats for details.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ext, support_string) ⇒ MagickOperations

Create a new MagickOperations for the given ext, reading the supported features of the format from support_string.



213
214
215
216
# File 'lib/thingfish/processor/image.rb', line 213

def initialize( ext, support_string )
  @ext = ext
  @blob, @read, @write, @multi = support_string.split('')
end

Instance Attribute Details

#blobObject (readonly)

Supported features



220
221
222
# File 'lib/thingfish/processor/image.rb', line 220

def blob
  @blob
end

#extObject (readonly)

Supported features



220
221
222
# File 'lib/thingfish/processor/image.rb', line 220

def ext
  @ext
end

#multiObject (readonly)

Supported features



220
221
222
# File 'lib/thingfish/processor/image.rb', line 220

def multi
  @multi
end

#readObject (readonly)

Supported features



220
221
222
# File 'lib/thingfish/processor/image.rb', line 220

def read
  @read
end

#writeObject (readonly)

Supported features



220
221
222
# File 'lib/thingfish/processor/image.rb', line 220

def write
  @write
end

Instance Method Details

#can_read?Boolean

Returns true if the operation string indicates that ImageMagick has native blob support for the associated type

Returns:

  • (Boolean)


243
244
245
# File 'lib/thingfish/processor/image.rb', line 243

def can_read?
  return (@read == 'r')
end

#can_write?Boolean

Returns true if the operation string indicates that ImageMagick has native blob support for the associated type

Returns:

  • (Boolean)


250
251
252
# File 'lib/thingfish/processor/image.rb', line 250

def can_write?
  return (@write == 'w')
end

#has_native_blob?Boolean

Returns true if the operation string indicates that ImageMagick has native blob support for the associated type

Returns:

  • (Boolean)


236
237
238
# File 'lib/thingfish/processor/image.rb', line 236

def has_native_blob?
  return (@blob == '*')
end

#supports_multi?Boolean

Returns true if the operation string indicates that ImageMagick has native blob support for the associated type

Returns:

  • (Boolean)


257
258
259
# File 'lib/thingfish/processor/image.rb', line 257

def supports_multi?
  return (@multi == '+')
end

#to_sObject

Return a human-readable description of the operations spec



224
225
226
227
228
229
230
231
# File 'lib/thingfish/processor/image.rb', line 224

def to_s
  return [
    self.has_native_blob? ? "Blob" : nil,
    self.can_read?      ? "Readable" : nil,
    self.can_write?     ? "Writable" : nil,
    self.supports_multi?  ? "Multi" : nil,
  ].compact.join(',')
end