Class: Miso::Image
- Inherits:
-
Object
- Object
- Miso::Image
- Defined in:
- lib/miso/image.rb,
lib/miso/factory.rb
Instance Attribute Summary collapse
-
#processor ⇒ Object
readonly
Returns the value of attribute processor.
Class Method Summary collapse
-
.crop(input_file, output_file, width, height, processor_class = nil) ⇒ Object
Class shortcut methods.
- .dimensions(input_file, processor_class = nil) ⇒ Object
- .factory(processor_class = Processor.processor_class) ⇒ Object
- .fit(input_file, output_file, width, height, processor_class = nil) ⇒ Object
Instance Method Summary collapse
-
#crop(width, height) ⇒ Object
Basic methods.
-
#crop_fitting(width, heigth) ⇒ Object
Combined methods.
- #dimensions ⇒ Object
- #fit(width, height) ⇒ Object
- #height ⇒ Object
-
#initialize(input_file, processor_class = nil) ⇒ Image
constructor
A new instance of Image.
- #width ⇒ Object
- #write(output_file) ⇒ Object
Constructor Details
#initialize(input_file, processor_class = nil) ⇒ Image
Returns a new instance of Image.
5 6 7 8 |
# File 'lib/miso/image.rb', line 5 def initialize(input_file, processor_class=nil) processor_class ||= Processor.processor_class @processor = processor_class.new(input_file) end |
Instance Attribute Details
#processor ⇒ Object (readonly)
Returns the value of attribute processor.
3 4 5 |
# File 'lib/miso/image.rb', line 3 def processor @processor end |
Class Method Details
.crop(input_file, output_file, width, height, processor_class = nil) ⇒ Object
Class shortcut methods
47 48 49 |
# File 'lib/miso/image.rb', line 47 def self.crop(input_file, output_file, width, height, processor_class = nil) new(input_file, processor_class).crop(width, height).write(output_file) end |
.dimensions(input_file, processor_class = nil) ⇒ Object
55 56 57 |
# File 'lib/miso/image.rb', line 55 def self.dimensions(input_file, processor_class = nil) new(input_file, processor_class).dimensions end |
.factory(processor_class = Processor.processor_class) ⇒ Object
3 4 5 |
# File 'lib/miso/factory.rb', line 3 def self.factory(processor_class = Processor.processor_class) Factory.new(processor_class) end |
.fit(input_file, output_file, width, height, processor_class = nil) ⇒ Object
51 52 53 |
# File 'lib/miso/image.rb', line 51 def self.fit(input_file, output_file, width, height, processor_class = nil) new(input_file, processor_class).fit(width, height).write(output_file) end |
Instance Method Details
#crop(width, height) ⇒ Object
Basic methods
12 13 14 15 |
# File 'lib/miso/image.rb', line 12 def crop(width, height) @processor.crop(width, height) return self end |
#crop_fitting(width, heigth) ⇒ Object
Combined methods
41 42 43 |
# File 'lib/miso/image.rb', line 41 def crop_fitting(width, heigth) fit(width, heigth).crop(width, heigth) end |
#dimensions ⇒ Object
22 23 24 |
# File 'lib/miso/image.rb', line 22 def dimensions @processor.dimensions end |
#fit(width, height) ⇒ Object
17 18 19 20 |
# File 'lib/miso/image.rb', line 17 def fit(width, height) @processor.fit(width, height) return self end |
#height ⇒ Object
30 31 32 |
# File 'lib/miso/image.rb', line 30 def height @processor.height end |
#width ⇒ Object
26 27 28 |
# File 'lib/miso/image.rb', line 26 def width @processor.width end |
#write(output_file) ⇒ Object
34 35 36 37 |
# File 'lib/miso/image.rb', line 34 def write(output_file) @processor.write(output_file) self.class.new(output_file, @processor.class) end |