Sha256: 9d8e97742731c4e8a31b0b7a6304b0f3c58a941d9c7212c3f062469084654291

Contents?: true

Size: 452 Bytes

Versions: 3

Compression:

Stored size: 452 Bytes

Contents

# frozen_string_literal: true
require 'set'

module Arbre
  module HTML

    # Holds a set of classes
    class ClassList < Set

      def self.build_from_string(class_names)
        new.add(class_names)
      end

      def add(class_names)
        class_names.to_s.split(" ").each do |class_name|
          super(class_name)
        end
        self
      end
      alias :<< :add

      def to_s
        to_a.join(" ")
      end

    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
arbre-1.7.0 lib/arbre/html/class_list.rb
arbre-1.6.0 lib/arbre/html/class_list.rb
arbre-1.5.0 lib/arbre/html/class_list.rb