Class: Tablette::Column
Direct Known Subclasses
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from Element
Instance Method Summary collapse
- #colspan(args) ⇒ Object
-
#initialize(*args, &block) ⇒ Column
constructor
A new instance of Column.
Methods inherited from Element
#element_to_html, #method_missing, #respond_to_missing?, #to_html
Constructor Details
#initialize(*args, &block) ⇒ Column
Returns a new instance of Column.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/tablette/columns.rb', line 5 def initialize(*args, &block) self.value = block self.key = args.first if args.first.is_a?(String) or args.first.is_a?(Symbol) config. = ->(member, index = nil) do classes = [] if self.key.present? classes << self.key.to_s end if index.kind_of? Numeric if index.odd? classes << "odd" else classes << "even" end end if classes.any? { :class => classes.join(" ") } else {} end end # Bypass block evaling: in this case it's not a config but a value formatter super(*args, &nil) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Tablette::Element
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
43 44 45 |
# File 'lib/tablette/columns.rb', line 43 def key @key end |
#value ⇒ Object
Returns the value of attribute value.
43 44 45 |
# File 'lib/tablette/columns.rb', line 43 def value @value end |
Instance Method Details
#colspan(args) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/tablette/columns.rb', line 35 def colspan(args) , = ([:override_html_options, :html_options], *args) = .merge [:colspan] end |