Class: Flowbite::Styles
- Inherits:
-
Object
- Object
- Flowbite::Styles
- Defined in:
- app/components/flowbite/styles.rb
Defined Under Namespace
Classes: StyleNotFoundError
Class Method Summary collapse
Instance Method Summary collapse
- #add_style(style_name, states_hash) ⇒ Object
- #fetch(style_name) ⇒ Object
-
#initialize ⇒ Styles
constructor
A new instance of Styles.
Constructor Details
#initialize ⇒ Styles
Returns a new instance of Styles.
30 31 32 |
# File 'app/components/flowbite/styles.rb', line 30 def initialize @styles = {} end |
Class Method Details
Instance Method Details
#add_style(style_name, states_hash) ⇒ Object
17 18 19 |
# File 'app/components/flowbite/styles.rb', line 17 def add_style(style_name, states_hash) @styles[style_name] = Flowbite::Style.new(states_hash) end |
#fetch(style_name) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'app/components/flowbite/styles.rb', line 21 def fetch(style_name) return @styles[style_name] if @styles.key?(style_name) raise \ StyleNotFoundError, "Style not found: #{style_name}. Available styles: " \ "#{@styles.keys.sort.join(", ")}" end |