Class: BootstrapBuilders::ClassAttributeHandler
- Inherits:
-
Object
- Object
- BootstrapBuilders::ClassAttributeHandler
- Defined in:
- lib/bootstrap_builders/class_attribute_handler.rb
Instance Attribute Summary collapse
-
#classes ⇒ Object
readonly
Returns the value of attribute classes.
Class Method Summary collapse
Instance Method Summary collapse
- #add(class_argument) ⇒ Object
- #include?(attr_class) ⇒ Boolean
-
#initialize(args) ⇒ ClassAttributeHandler
constructor
A new instance of ClassAttributeHandler.
- #remove(class_argument) ⇒ Object
Constructor Details
#initialize(args) ⇒ ClassAttributeHandler
Returns a new instance of ClassAttributeHandler.
8 9 10 |
# File 'lib/bootstrap_builders/class_attribute_handler.rb', line 8 def initialize(args) @classes = convert_to_array(args.fetch(:class)) end |
Instance Attribute Details
#classes ⇒ Object (readonly)
Returns the value of attribute classes.
2 3 4 |
# File 'lib/bootstrap_builders/class_attribute_handler.rb', line 2 def classes @classes end |
Class Method Details
.short(classes) ⇒ Object
4 5 6 |
# File 'lib/bootstrap_builders/class_attribute_handler.rb', line 4 def self.short(classes) BootstrapBuilders::ClassAttributeHandler.new(class: classes).classes end |
Instance Method Details
#add(class_argument) ⇒ Object
12 13 14 |
# File 'lib/bootstrap_builders/class_attribute_handler.rb', line 12 def add(class_argument) @classes += convert_to_array(class_argument) end |
#include?(attr_class) ⇒ Boolean
24 25 26 |
# File 'lib/bootstrap_builders/class_attribute_handler.rb', line 24 def include?(attr_class) @classes.include?(attr_class) end |
#remove(class_argument) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/bootstrap_builders/class_attribute_handler.rb', line 16 def remove(class_argument) if class_argument.is_a?(Array) @classes -= class_argument else @classes.delete(class_argument) end end |