Class: Identify::Image::PBM
Overview
Class Method Summary
collapse
Instance Method Summary
collapse
#as_hash, formats, identify, inherited, parse
Class Method Details
.handle?(data) ⇒ Boolean
98
99
100
|
# File 'lib/identify.rb', line 98
def self.handle? data
%r{\AP[1-6]}.match(data)
end
|
Instance Method Details
107
108
109
110
111
112
113
|
# File 'lib/identify.rb', line 107
def format type
case type
when 'P1', 'P4' then 'pbm'
when 'P2', 'P5' then 'pgm'
when 'P3', 'P6' then 'ppm'
end
end
|
#parse(data) ⇒ Object
102
103
104
105
|
# File 'lib/identify.rb', line 102
def parse data
type, dims = data[0..4096].split(/\n+/).reject {|line| %r{\A#}.match(line)}.take(2)
as_hash format(type), *dims.split(/\s+/)
end
|