Class: Noventius::ColumnsGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/noventius/columns_group.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, columns, options = {}) ⇒ ColumnsGroup

Returns a new instance of ColumnsGroup.



7
8
9
10
11
12
13
# File 'lib/noventius/columns_group.rb', line 7

def initialize(name, columns, options = {})
  @name = name.to_sym
  @columns = columns
  @label = options.delete(:label) || @name.to_s
  @label = instance_exec(&@label) if @label.is_a?(Proc)
  @options = options
end

Instance Attribute Details

#columnsObject (readonly)

Returns the value of attribute columns.



5
6
7
# File 'lib/noventius/columns_group.rb', line 5

def columns
  @columns
end

#labelObject (readonly)

Returns the value of attribute label.



5
6
7
# File 'lib/noventius/columns_group.rb', line 5

def label
  @label
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/noventius/columns_group.rb', line 5

def name
  @name
end

Instance Method Details

#columns_for_level(level) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/noventius/columns_group.rb', line 27

def columns_for_level(level)
  if level == 1
    @columns
  else
    @columns.select { |column| column.is_a?(ColumnsGroup) }
      .flat_map { |child| child.columns_for_level(level - 1) }
  end
end

#deep_dupObject



19
20
21
# File 'lib/noventius/columns_group.rb', line 19

def deep_dup
  Marshal.load(Marshal.dump(self))
end

#depthObject



23
24
25
# File 'lib/noventius/columns_group.rb', line 23

def depth
  1 + (@columns.map(&:depth).max || 0)
end

#html_optionsObject



15
16
17
# File 'lib/noventius/columns_group.rb', line 15

def html_options
  @options[:html_options] || {}
end