Class: JPEG2moro

Inherits:
Object
  • Object
show all
Defined in:
lib/jpeg2moro.rb

Constant Summary collapse

DEBUG =
1
VERSION =
"0.0.1"
DEFAULT_ALPHA_DEPTH =
8
DEFAULT_QUALITY =
70

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ JPEG2moro



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/jpeg2moro.rb', line 19

def initialize(options = {})
  if options.kind_of?(Hash) 
    @file = options[:file]
    @data = options[:data]
  else
    @file = options
  end

  @data = File.read(@file) if @file
  debug "read %d bytes" % [@data.length]
end

Class Attribute Details

.debugObject

Returns the value of attribute debug.



16
17
18
# File 'lib/jpeg2moro.rb', line 16

def debug
  @debug
end

Class Method Details

.with_data(data) ⇒ Object



31
32
33
# File 'lib/jpeg2moro.rb', line 31

def self.with_data(data)
  return JPEG2moro.new(:data => data)
end

Instance Method Details

#save(output_file, options = {}) ⇒ Object

save output_file with the given options



40
41
42
43
# File 'lib/jpeg2moro.rb', line 40

def save(output_file, options = {})
  output = convert(options)
  File.open(output_file, "w") { |f| f.print output }
end

#to_sObject



35
36
37
# File 'lib/jpeg2moro.rb', line 35

def to_s
  @data
end