Class: Maglove::Widgets::Columns

Inherits:
Base
  • Object
show all
Defined in:
lib/maglove/widgets/columns.rb

Defined Under Namespace

Modules: Helpers

Instance Attribute Summary collapse

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

#typeloft_widget_options

Constructor Details

#initialize(options) ⇒ Columns

Returns a new instance of Columns.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/maglove/widgets/columns.rb', line 8

def initialize(options)
  super(options)
  @column_count = 0
  column_array = @options[:columns].to_s.split("x")
  if column_array.length == 1
    @total_columns = column_array[0].to_i
    @columns = Array.new(@total_columns) { 12 / @total_columns }
  else
    @total_columns = column_array.length
    @columns = column_array
  end
end

Instance Attribute Details

#column_countObject (readonly)

Returns the value of attribute column_count.



5
6
7
# File 'lib/maglove/widgets/columns.rb', line 5

def column_count
  @column_count
end

#columnsObject (readonly)

Returns the value of attribute columns.



4
5
6
# File 'lib/maglove/widgets/columns.rb', line 4

def columns
  @columns
end

#total_columnsObject (readonly)

Returns the value of attribute total_columns.



6
7
8
# File 'lib/maglove/widgets/columns.rb', line 6

def total_columns
  @total_columns
end

Instance Method Details

#defaultsObject



38
39
40
41
42
43
44
45
# File 'lib/maglove/widgets/columns.rb', line 38

def defaults
  {
    columns: "2",
    style: "default",
    margin_bottom: "",
    collapse_options: "sm"
  }
end

#identifierObject



34
35
36
# File 'lib/maglove/widgets/columns.rb', line 34

def identifier
  "columns"
end

#next_spanObject



21
22
23
24
25
# File 'lib/maglove/widgets/columns.rb', line 21

def next_span
  value = @columns[@column_count]
  @column_count += 1
  value
end

#row_optionsObject



27
28
29
30
31
32
# File 'lib/maglove/widgets/columns.rb', line 27

def row_options
  {
    class: "row row-#{@options[:style]}",
    style: style_string(@options, :margin_bottom)
  }
end