Class: LegacyParser
- Inherits:
-
Object
- Object
- LegacyParser
- Defined in:
- lib/legacyparser.rb
Overview
the regular ImageParser.
Instance Attribute Summary collapse
-
#con ⇒ Object
Accessors for an ImageParser and regular binary parsing.
-
#img ⇒ Object
Accessors for an ImageParser and regular binary parsing.
Instance Method Summary collapse
-
#initialize(file = nil) ⇒ LegacyParser
constructor
A new instance of LegacyParser.
-
#parse_bmp(info) ⇒ Object
Parse a BMP file.
-
#parse_ppm(info) ⇒ Object
Parse a PPM file.
-
#parse_ptf(info) ⇒ Object
Parse a PTF file.
Constructor Details
#initialize(file = nil) ⇒ LegacyParser
Returns a new instance of LegacyParser.
11 12 13 14 |
# File 'lib/legacyparser.rb', line 11 def initialize(file=nil) @img = ImageParser.new(file) if file @con = File.read(file, mode: 'rb') if file end |
Instance Attribute Details
#con ⇒ Object
Accessors for an ImageParser and regular binary parsing.
10 11 12 |
# File 'lib/legacyparser.rb', line 10 def con @con end |
#img ⇒ Object
Accessors for an ImageParser and regular binary parsing.
10 11 12 |
# File 'lib/legacyparser.rb', line 10 def img @img end |
Instance Method Details
#parse_bmp(info) ⇒ Object
Parse a BMP file.
unfinished..
33 34 35 36 37 38 39 40 |
# File 'lib/legacyparser.rb', line 33 def parse_bmp(info) info[:fhType] = @con[0, 2] if @con[0, 2] == "BM" info[:fhSize] = @con[2, 4].unpack("l<")[0] info[:fhReserved] = @con[5, 2].unpack("C*")[0] info[:fhReserved1] = @con[5, 2].unpack("C*")[1] info[:fhOffbits] = @con[7, 4].unpack("C*") # ----------------------------------------------- end |
#parse_ppm(info) ⇒ Object
Parse a PPM file.
See ImageParser docs for more.
19 20 21 |
# File 'lib/legacyparser.rb', line 19 def parse_ppm(info) @img.parse_ppm(info) end |
#parse_ptf(info) ⇒ Object
Parse a PTF file.
See ImageParser docs for more.
26 27 28 |
# File 'lib/legacyparser.rb', line 26 def parse_ptf(info) @img.parse_ppm(info) end |