Displaying 1 result from an estimated 1 matches for "style_array".
2006 Apr 05
0
each_with_styles, for adding CSS classes
...# :not_middle -- first and last only
# :odd -- every other, starting with the first
# :even -- every other, starting with the second
class Array
def each_with_styles(styles)
styles = Hash.new unless styles && styles.class == Hash
each_with_index do |item, index|
style_array = Array.new
style_array << styles[:all]
style_array << (index == 0 ? styles[:first] : styles[:not_first])
style_array << (index == (length-1) ? styles[:last] : styles[:not_last])
style_array << (index % 2 == 0 ? styles[:even] : styles[:odd])...