Class: Blueprint::CustomLayout
- Inherits:
-
Object
- Object
- Blueprint::CustomLayout
- Defined in:
- lib/template/css/blueprint/lib/blueprint/custom_layout.rb
Overview
Generates a custom grid file, using ERB to evaluate custom settings
Constant Summary collapse
- CSS_ERB_FILE =
path to ERB file used for CSS template
File.join(Blueprint::LIB_PATH, 'grid.css.erb')
Instance Attribute Summary collapse
-
#column_count ⇒ Object
Column count of generated CSS.
-
#column_width ⇒ Object
Column width (in pixels) of generated CSS.
-
#gutter_width ⇒ Object
Gutter width (in pixels) of generated CSS.
- #input_border ⇒ Object
- #input_padding ⇒ Object
Instance Method Summary collapse
-
#default? ⇒ Boolean
Boolean value if current settings are Blueprint’s defaults.
-
#generate_grid_css ⇒ Object
Loads grid.css.erb file, binds it to current instance, and returns output.
-
#initialize(options = {}) ⇒ CustomLayout
constructor
Options *
options
*:column_count
– Sets the column count of generated CSS *:column_width
– Sets the column width (in pixels) of generated CSS *:gutter_width
– Sets the gutter width (in pixels) of generated CSS *:input_padding
– Sets the input padding width (in pixels) of generated CSS *:input_border
– Sets the border width (in pixels) of generated CSS. -
#page_width ⇒ Object
Returns page width (in pixels).
Constructor Details
#initialize(options = {}) ⇒ CustomLayout
Options
-
options
-
:column_count
– Sets the column count of generated CSS -
:column_width
– Sets the column width (in pixels) of generated CSS -
:gutter_width
– Sets the gutter width (in pixels) of generated CSS -
:input_padding
– Sets the input padding width (in pixels) of generated CSS -
:input_border
– Sets the border width (in pixels) of generated CSS
-
46 47 48 49 50 51 52 |
# File 'lib/template/css/blueprint/lib/blueprint/custom_layout.rb', line 46 def initialize( = {}) @column_count = [:column_count] @column_width = [:column_width] @gutter_width = [:gutter_width] @input_padding = [:input_padding] @input_border = [:input_border] end |
Instance Attribute Details
#column_count ⇒ Object
Column count of generated CSS. Returns itself or Blueprint’s default
12 13 14 |
# File 'lib/template/css/blueprint/lib/blueprint/custom_layout.rb', line 12 def column_count (@column_count || Blueprint::COLUMN_COUNT).to_i end |
#column_width ⇒ Object
Column width (in pixels) of generated CSS. Returns itself or Blueprint’s default
17 18 19 |
# File 'lib/template/css/blueprint/lib/blueprint/custom_layout.rb', line 17 def column_width (@column_width || Blueprint::COLUMN_WIDTH).to_i end |
#gutter_width ⇒ Object
Gutter width (in pixels) of generated CSS. Returns itself or Blueprint’s default
22 23 24 |
# File 'lib/template/css/blueprint/lib/blueprint/custom_layout.rb', line 22 def gutter_width (@gutter_width || Blueprint::GUTTER_WIDTH).to_i end |
#input_border ⇒ Object
30 31 32 |
# File 'lib/template/css/blueprint/lib/blueprint/custom_layout.rb', line 30 def input_border (@input_border || Blueprint::INPUT_BORDER).to_i end |
#input_padding ⇒ Object
26 27 28 |
# File 'lib/template/css/blueprint/lib/blueprint/custom_layout.rb', line 26 def input_padding (@input_padding || Blueprint::INPUT_PADDING).to_i end |
Instance Method Details
#default? ⇒ Boolean
Boolean value if current settings are Blueprint’s defaults
55 56 57 58 59 60 61 |
# File 'lib/template/css/blueprint/lib/blueprint/custom_layout.rb', line 55 def default? self.column_width == Blueprint::COLUMN_WIDTH && self.column_count == Blueprint::COLUMN_COUNT && self.gutter_width == Blueprint::GUTTER_WIDTH && self.input_padding == Blueprint::INPUT_PADDING && self.input_border == Blueprint::INPUT_BORDER end |
#generate_grid_css ⇒ Object
Loads grid.css.erb file, binds it to current instance, and returns output
64 65 66 67 68 69 70 |
# File 'lib/template/css/blueprint/lib/blueprint/custom_layout.rb', line 64 def generate_grid_css # loads up erb template to evaluate custom widths css = ERB::new(File.path_to_string(CustomLayout::CSS_ERB_FILE)) # bind it to this instance css.result(binding) end |
#page_width ⇒ Object
Returns page width (in pixels)
35 36 37 |
# File 'lib/template/css/blueprint/lib/blueprint/custom_layout.rb', line 35 def page_width column_count * (column_width + gutter_width) - gutter_width end |