Class: Mathtype::WmfFileParser
- Inherits:
 - 
      FileParser
      
        
- Object
 - FileParser
 - Mathtype::WmfFileParser
 
 
- Defined in:
 - lib/file_parser/wmf.rb
 
Instance Attribute Summary
Attributes inherited from FileParser
Instance Method Summary collapse
- #extract_mtef_from_mfcomment(comment) ⇒ Object
 - 
  
    
      #initialize(path)  ⇒ WmfFileParser 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of WmfFileParser.
 
Methods inherited from FileParser
Constructor Details
#initialize(path) ⇒ WmfFileParser
Returns a new instance of WmfFileParser.
      3 4 5 6  | 
    
      # File 'lib/file_parser/wmf.rb', line 3 def initialize(path) super(path) extract_mtef_from_mfcomment(@raw) end  | 
  
Instance Method Details
#extract_mtef_from_mfcomment(comment) ⇒ Object
      8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26  | 
    
      # File 'lib/file_parser/wmf.rb', line 8 def extract_mtef_from_mfcomment(comment) match = comment.match("MathTypeUU") if match lenpos = match.end(0) len = comment[lenpos..lenpos+1].unpack("H*")[0].to_i 16 start = lenpos + 2 else match = comment.match("AppsMFCC\x01") raise ::NotImplementedError, "No MathType Equation found in wmf" unless match len_start = match.end(0) totallen = comment[len_start..len_start + 3].reverse.chars.rotate(-1).join.unpack("H*")[0].to_i 16 datalen = comment[len_start + 4 .. len_start + 7].reverse.chars.rotate(-1).join.unpack("H*")[0].to_i 16 signature = comment[len_start + 8.. -1].match(/.+?\x00/) raise ::NotImplementedError, "Equation split over multiple comments" unless totallen == datalen start = len_start + 8 + signature.end(0) len = datalen end @equation = comment[start..(start + len)] end  |