Class: Apropos::ClassList

Inherits:
Object
  • Object
show all
Defined in:
lib/apropos/class_list.rb

Overview

ClassList wraps a list of CSS class selectors with several abilities:

  • Can be combined with other ClassLists

  • Can be compared to MediaQuery or ClassList objects via #sort_value, #type

  • Can be converted to CSS output

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(list, sort_value = 0) ⇒ ClassList

Returns a new instance of ClassList.



9
10
11
12
# File 'lib/apropos/class_list.rb', line 9

def initialize(list, sort_value=0)
  @list = list
  @sort_value = sort_value
end

Instance Attribute Details

#listObject (readonly)

Returns the value of attribute list.



7
8
9
# File 'lib/apropos/class_list.rb', line 7

def list
  @list
end

#sort_valueObject (readonly)

Returns the value of attribute sort_value.



7
8
9
# File 'lib/apropos/class_list.rb', line 7

def sort_value
  @sort_value
end

Instance Method Details

#combine(other) ⇒ Object



14
15
16
# File 'lib/apropos/class_list.rb', line 14

def combine(other)
  self.class.new(list + other.list)
end

#to_cssObject



18
19
20
# File 'lib/apropos/class_list.rb', line 18

def to_css
  list.join(', ')
end

#typeObject



22
23
24
# File 'lib/apropos/class_list.rb', line 22

def type
  "class"
end