Class: RideTheStreetcar::ClassList

Inherits:
Object
  • Object
show all
Includes:
Streamlined::Renderable
Defined in:
lib/ride_the_streetcar/class_list.rb

Instance Method Summary collapse

Instance Method Details

#add(class_names) ⇒ Object



7
8
9
10
11
# File 'lib/ride_the_streetcar/class_list.rb', line 7

def add(class_names)
  joined_names = Array(class_names).join(",")

  statements << { add: joined_names }
end

#remove(class_names) ⇒ Object



13
14
15
16
17
# File 'lib/ride_the_streetcar/class_list.rb', line 13

def remove(class_names)
  joined_names = Array(class_names).join(",")

  statements << { remove: joined_names }
end

#statementsObject



5
# File 'lib/ride_the_streetcar/class_list.rb', line 5

def statements = @statements ||= []

#templateObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ride_the_streetcar/class_list.rb', line 23

def template
  html -> { <<~HTML
    #{html_map(statements) do |statement|
      html -> { <<~HTML
        <sc-class-list #{html_attributes statement}></sc-class-list>
      HTML
      }
    end}
  HTML
  }
end

#toggle(name, force: nil) ⇒ Object



19
20
21
# File 'lib/ride_the_streetcar/class_list.rb', line 19

def toggle(name, force: nil)
  statements << { toggle: name, force: }
end