Class: Kramdown::PlantUml::StyleBuilder
- Defined in:
- lib/kramdown-plantuml/style_builder.rb
Overview
Builds a CSS style string from a hash of style properties.
Instance Method Summary collapse
- #[]=(key, value) ⇒ Object
-
#initialize ⇒ StyleBuilder
constructor
A new instance of StyleBuilder.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ StyleBuilder
Returns a new instance of StyleBuilder.
9 10 11 |
# File 'lib/kramdown-plantuml/style_builder.rb', line 9 def initialize @hash = {} end |
Instance Method Details
#[]=(key, value) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/kramdown-plantuml/style_builder.rb', line 13 def []=(key, value) return if key.nil? case key when :width, :height if none(value) @hash.delete(key) else @hash[key] = value end else self.style = value end end |
#to_s ⇒ Object
28 29 30 |
# File 'lib/kramdown-plantuml/style_builder.rb', line 28 def to_s @hash.sort_by { |key, _| key }.map { |key, value| "#{key}:#{value}" }.join(';') end |