Sha256: d676456194f97be6b6ed502db99ec13aa9c39f3ef3110ebdcee5aedb209535d3

Contents?: true

Size: 761 Bytes

Versions: 4

Compression:

Stored size: 761 Bytes

Contents

module CheapRedWine
  module Image
    class Writer 
      def initialize(image, utility = 'hb-view')
        @utility = utility
        @image = image
      end

      def args
        [font_file, text, margin, foreground, features, size]
      end

      def exec
        IO.popen(args.unshift(@utility))
      end

      private

      def font_file
        "--font-file=#{@image.font.path}"
      end

      def text
        "--text=#{@image.text}"
      end

      def size
        "--font-size=#{@image.size}"
      end

      def foreground 
        "--foreground=#{@image.color}"
      end 

      def margin
        "--margin=#{@image.margin}"
      end

      def features
        "--features=#{@image.features.join(",")}"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cheapredwine-0.2.0 lib/cheapredwine/image/writer.rb
cheapredwine-0.1.1 lib/cheapredwine/image/writer.rb
cheapredwine-0.1.0 lib/cheapredwine/image/writer.rb
cheapredwine-0.0.2 lib/cheapredwine/image/writer.rb