Class: Compass::GridBuilder
- Includes:
- Actions
- Defined in:
- lib/compass/grid_builder.rb
Constant Summary
Constants inherited from PNG
PNG::BITS, PNG::CRC_TABLE, PNG::NONE, PNG::RGB
Instance Attribute Summary collapse
-
#able_to_generate ⇒ Object
readonly
Returns the value of attribute able_to_generate.
-
#column_width ⇒ Object
readonly
Returns the value of attribute column_width.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#gutter_width ⇒ Object
readonly
Returns the value of attribute gutter_width.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Attributes included from Actions
Instance Method Summary collapse
-
#generate! ⇒ Object
generates (overwriting if necessary) grid.png image to be tiled in background.
-
#initialize(options = {}) ⇒ GridBuilder
constructor
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. - #working_path ⇒ Object
Methods included from Actions
#basename, #copy, #directory, #log_action, #process_erb, #relativize, #remove, #separate, #strip_trailing_separator, #write_file
Methods inherited from PNG
chunk, crc, #png_join, #to_blob
Constructor Details
#initialize(options = {}) ⇒ GridBuilder
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
-
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/compass/grid_builder.rb', line 66 def initialize(={}) @column_width = [:column_width] || 0 gutter_width = [:gutter_width] || 0 height = [:height] || 20 width = @column_width + gutter_width width = 10 if width == 0 @filename = [:filename] @options = super(width, height, [0xe9,0xe9,0xe9]) end |
Instance Attribute Details
#able_to_generate ⇒ Object (readonly)
Returns the value of attribute able_to_generate.
58 59 60 |
# File 'lib/compass/grid_builder.rb', line 58 def able_to_generate @able_to_generate end |
#column_width ⇒ Object (readonly)
Returns the value of attribute column_width.
58 59 60 |
# File 'lib/compass/grid_builder.rb', line 58 def column_width @column_width end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
58 59 60 |
# File 'lib/compass/grid_builder.rb', line 58 def filename @filename end |
#gutter_width ⇒ Object (readonly)
Returns the value of attribute gutter_width.
58 59 60 |
# File 'lib/compass/grid_builder.rb', line 58 def gutter_width @gutter_width end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
58 59 60 |
# File 'lib/compass/grid_builder.rb', line 58 def @options end |
Instance Method Details
#generate! ⇒ Object
generates (overwriting if necessary) grid.png image to be tiled in background
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# 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 [: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, , true) end |
#working_path ⇒ Object
80 81 82 |
# File 'lib/compass/grid_builder.rb', line 80 def working_path [:working_path] end |