class Compass::GridBuilder

Attributes

able_to_generate[R]
column_width[R]
filename[R]
gutter_width[R]
options[R]

Public Class Methods

new(options={}) click to toggle source

Options

  • options

    • :column_width – Width (in pixels) of current grid column

    • :gutter_width – Width (in pixels) of current grid gutter

    • :height – Height (in pixels) of a row

    • :filename – Output path of grid.png file

Calls superclass method Compass::PNG.new
# File lib/compass/grid_builder.rb, line 66
def initialize(options={})
  @column_width = options[:column_width] || 0
  gutter_width = options[:gutter_width] || 0

  height = options[:height] || 20
  width = @column_width + gutter_width
  width = 10 if width == 0

  @filename = options[:filename]
  @options = options

  super(width, height, [0xe9,0xe9,0xe9])
end

Public Instance Methods

generate!() click to toggle source

generates (overwriting if necessary) grid.png image to be tiled in background

# File lib/compass/grid_builder.rb, line 85
def generate!
  (0...@height-1).each do |line|
    @data[line] = Array.new(@width){|x| x < @column_width ? [0xe8, 0xef, 0xfb] : [0xff,0xff,0xff] }
  end

  if File.exists?(filename)
    if options[:force]
      overwrite = true
    else
      msg = "#{filename} already exists. Overwrite with --force."
      raise Compass::FilesystemConflict.new(msg)
    end
  end
  directory File.dirname(filename)
  write_file(filename, self.to_blob, options, true)
end
working_path() click to toggle source
# File lib/compass/grid_builder.rb, line 80
def working_path
  options[:working_path]
end