Class: TableMe::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/table_me/builder.rb

Overview

This class is responsible for building the various elements of the table through a blog passed into the table_for_presenter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table_options) ⇒ Builder

Returns a new instance of Builder.



10
11
12
13
14
# File 'lib/table_me/builder.rb', line 10

def initialize table_options
  self.options = table_options
  @columns = []
  @names = []
end

Instance Attribute Details

#columnsObject (readonly)

Returns the value of attribute columns.



9
10
11
# File 'lib/table_me/builder.rb', line 9

def columns
  @columns
end

#filtersObject (readonly)

Returns the value of attribute filters.



9
10
11
# File 'lib/table_me/builder.rb', line 9

def filters
  @filters
end

#namesObject (readonly)

Returns the value of attribute names.



9
10
11
# File 'lib/table_me/builder.rb', line 9

def names
  @names
end

#optionsObject

Returns the value of attribute options.



8
9
10
# File 'lib/table_me/builder.rb', line 8

def options
  @options
end

Instance Method Details

#clear_filterObject



31
32
33
34
# File 'lib/table_me/builder.rb', line 31

def clear_filter
  # TODO this seems a bit hacky to me, Will want to rework this at some point
  filters.last.display_clear
end

#column(name, options = {}, &block) ⇒ Object

Define a column



17
18
19
20
# File 'lib/table_me/builder.rb', line 17

def column name,options = {}, &block
  @columns << TableMe::Column.new(name,options, &block)
  @names << name
end

#filter(name) ⇒ Object

define a filter



23
24
25
# File 'lib/table_me/builder.rb', line 23

def filter name
  TableMe::Filter.new(options, name)
end