Class: Kramdown::PlantUml::StyleBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/kramdown-plantuml/style_builder.rb

Overview

Builds a CSS style string from a hash of style properties.

Instance Method Summary collapse

Constructor Details

#initializeStyleBuilder

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_sObject



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