class ActionTable::BootstrapStyles
Constants
- BOOTSTRAP_TABLE_STYLES
.thead-light or .thead-dark
<th scope="row">1</th> <caption>List of users</caption> # directly under <table>
- BOOTSTRAP_TABLE_WRAPERS
- BOOTSTRAP_UTILS
All the below can be used on <table>, <thead>, <tr>, <td>
Public Class Methods
new(styles)
click to toggle source
# File lib/action_table/bootstrap_styles.rb, line 45 def initialize(styles) @styles = Array(styles).map { |style| style.to_s.tr('_', '-') } @responsive_wrapper_class = nil @table_classes = nil validate_styles!(@styles) end
Public Instance Methods
responsive_wrapper_class()
click to toggle source
# File lib/action_table/bootstrap_styles.rb, line 53 def responsive_wrapper_class return @responsive_wrapper_class if @responsive_wrapper_class wrappers = BOOTSTRAP_TABLE_WRAPERS.select { |style| @styles.include?(style) } return if wrappers.empty? @responsive_wrapper_class = wrappers.map do |style| "table-#{style}" if wrapper_class?(style) end.join(' ') end
table_classes()
click to toggle source
# File lib/action_table/bootstrap_styles.rb, line 64 def table_classes return @table_classes if @table_classes style_classes = @styles.map do |style| "table-#{style}" if table_class?(style) end.compact @table_classes = "table #{style_classes.join(' ')}" end
Private Instance Methods
table_class?(style)
click to toggle source
# File lib/action_table/bootstrap_styles.rb, line 76 def table_class?(style) BOOTSTRAP_TABLE_STYLES.include?(style) end
validate_styles!(styles)
click to toggle source
# File lib/action_table/bootstrap_styles.rb, line 84 def validate_styles!(styles) styles.each do |style| next if table_class?(style) || wrapper_class?(style) raise( ArgumentError, "unknown bootstrap style #{style}, must be in #{BOOTSTRAP_TABLE_STYLES}", ) end end
wrapper_class?(style)
click to toggle source
# File lib/action_table/bootstrap_styles.rb, line 80 def wrapper_class?(style) BOOTSTRAP_TABLE_WRAPERS.include?(style) end