Class: Maglove::Widget::LegacyColumns
- Defined in:
- lib/maglove/widget/columns.rb
Instance Attribute Summary collapse
-
#column_count ⇒ Object
readonly
Returns the value of attribute column_count.
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#total_columns ⇒ Object
readonly
Returns the value of attribute total_columns.
Attributes inherited from Base
Instance Method Summary collapse
- #column(&block) ⇒ Object
- #defaults ⇒ Object
- #identifier ⇒ Object
-
#initialize(scope, options = {}) ⇒ LegacyColumns
constructor
A new instance of LegacyColumns.
- #render(&block) ⇒ Object
Methods inherited from V1
#drop_container, #widget_options
Methods inherited from Base
#style_string, #widget_options
Constructor Details
#initialize(scope, options = {}) ⇒ LegacyColumns
Returns a new instance of LegacyColumns.
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/maglove/widget/columns.rb', line 25 def initialize(scope, = {}) super @column_count = 0 column_array = @options[:columns].to_s.split("x").map(&:to_i) if column_array.length == 1 @total_columns = column_array[0] @columns = Array.new(@total_columns) { 12 / @total_columns } else @total_columns = column_array.length @columns = column_array end end |
Instance Attribute Details
#column_count ⇒ Object (readonly)
Returns the value of attribute column_count.
22 23 24 |
# File 'lib/maglove/widget/columns.rb', line 22 def column_count @column_count end |
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
21 22 23 |
# File 'lib/maglove/widget/columns.rb', line 21 def columns @columns end |
#total_columns ⇒ Object (readonly)
Returns the value of attribute total_columns.
23 24 25 |
# File 'lib/maglove/widget/columns.rb', line 23 def total_columns @total_columns end |
Instance Method Details
#column(&block) ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/maglove/widget/columns.rb', line 59 def column(&block) span = columns[column_count] raise "ERROR: Row does not allow column at position #{column_count}" unless span @column_count += 1 phone_cols = ([:collapse_options] == "xs") ? span : "12" haml_tag :div, class: "column col-#{phone_cols} col-tablet-#{span} col-#{[:collapse_options]}-#{span}" do yield self if block_given? drop_container end end |
#defaults ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/maglove/widget/columns.rb', line 42 def defaults { columns: "2", style: "default", margin_bottom: "", collapse_options: "sm" } end |
#identifier ⇒ Object
38 39 40 |
# File 'lib/maglove/widget/columns.rb', line 38 def identifier "columns" end |
#render(&block) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/maglove/widget/columns.rb', line 51 def render(&block) super do haml_tag :div, do yield self if block_given? end end end |