Class: Colorant::Processer
- Inherits:
-
Object
- Object
- Colorant::Processer
- Defined in:
- lib/colorant/processer.rb
Instance Attribute Summary collapse
-
#colors ⇒ Object
readonly
Returns the value of attribute colors.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#depth ⇒ Object
readonly
Returns the value of attribute depth.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(file, options = {}) ⇒ Processer
constructor
A new instance of Processer.
- #process! ⇒ Object
Constructor Details
#initialize(file, options = {}) ⇒ Processer
Returns a new instance of Processer.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/colorant/processer.rb', line 5 def initialize(file, = {}) begin File.open(file) rescue=>e raise ArgumentError.new "#{file} does not exist or is not a valid image file" end @file = file @colors = [:colors] ? [:colors].to_i : 8 @depth = [:depth] ? [:depth].to_i : 16 @reporter_options = {:reporter => [:reporter], :extended => [:extended]} @data = [] end |
Instance Attribute Details
#colors ⇒ Object (readonly)
Returns the value of attribute colors.
3 4 5 |
# File 'lib/colorant/processer.rb', line 3 def colors @colors end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
3 4 5 |
# File 'lib/colorant/processer.rb', line 3 def data @data end |
#depth ⇒ Object (readonly)
Returns the value of attribute depth.
3 4 5 |
# File 'lib/colorant/processer.rb', line 3 def depth @depth end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
3 4 5 |
# File 'lib/colorant/processer.rb', line 3 def file @file end |
Class Method Details
.process(*args) ⇒ Object
26 27 28 29 |
# File 'lib/colorant/processer.rb', line 26 def process(*args) instance = new(*args) instance.process! end |
Instance Method Details
#process! ⇒ Object
19 20 21 22 23 |
# File 'lib/colorant/processer.rb', line 19 def process! raw_data = `convert #{file} -gravity Center -crop 80x60% +repage -format %c -colors #{colors} -depth #{depth} histogram:info:- | sort -r -k 1` @data = Parser.parse(raw_data) Reporter.report(@data, @reporter_options) end |