Class: Svg::Style

Inherits:
String
  • Object
show all
Defined in:
lib/svg.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fillObject

Returns the value of attribute fill.



28
29
30
# File 'lib/svg.rb', line 28

def fill
  @fill
end

#fill_opacityObject

Returns the value of attribute fill_opacity.



28
29
30
# File 'lib/svg.rb', line 28

def fill_opacity
  @fill_opacity
end

#opacityObject

Returns the value of attribute opacity.



28
29
30
# File 'lib/svg.rb', line 28

def opacity
  @opacity
end

#strokeObject

Returns the value of attribute stroke.



28
29
30
# File 'lib/svg.rb', line 28

def stroke
  @stroke
end

#stroke_opacityObject

Returns the value of attribute stroke_opacity.



28
29
30
# File 'lib/svg.rb', line 28

def stroke_opacity
  @stroke_opacity
end

#stroke_widthObject

Returns the value of attribute stroke_width.



28
29
30
# File 'lib/svg.rb', line 28

def stroke_width
  @stroke_width
end

Instance Method Details

#attr_to_s(attr_name, attr_val) ⇒ Object



42
43
44
45
# File 'lib/svg.rb', line 42

def attr_to_s (attr_name, attr_val)
  return '' if attr_val.nil?
  " #{attr_name}:#{attr_val};" if not attr_val.to_s.empty?
end

#to_sObject



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/svg.rb', line 29

def to_s
  string_val = attr_to_s 'fill', fill
  string_val += attr_to_s 'stroke', stroke
  string_val += attr_to_s 'stroke-width', stroke_width
  string_val += attr_to_s 'opacity', opacity
  string_val += attr_to_s 'fill-opacity', fill_opacity
  string_val += attr_to_s 'stroke-opacity', stroke_opacity
  if not string_val.empty?
    string_val.strip!
    string_val.chop!
  end
  return string_val
end