Sha256: afccdc6fc3ff9d540ee69164e2711d22b2aa074143bb1251fa7d97986bb83bdc

Contents?: true

Size: 761 Bytes

Versions: 1

Compression:

Stored size: 761 Bytes

Contents

require 'nokogiri'

module CheapRedWine
  class NokogiriParser
    @@parser = Nokogiri::XML::Document

    def self.parse(file)
      @@parser.parse(file)
    end
  end

  module TTX
    class Parser
      def initialize(file, xml_parser = NokogiriParser)
        @document = xml_parser.parse(file)
      end

      def features
        @document.css('FeatureTag').map do |feature| 
          feature.attr('value') 
        end.uniq
      end

      def font_name 
        namerecord(4).first.text.strip
      end

      def family_name
        namerecord(1).first.text.strip
      end

      def style
        namerecord(2).first.text.strip
      end

      def namerecord(id)
        @document.xpath("//namerecord[@nameID=#{id}]")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cheapredwine-0.1.1 lib/cheapredwine/ttx/parser.rb