Class: Xomponent::Style

Inherits:
Object
  • Object
show all
Defined in:
lib/Xomponent/Style.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStyle

Returns a new instance of Style.



4
5
6
# File 'lib/Xomponent/Style.rb', line 4

def initialize
  @s = ''
end

Instance Attribute Details

#s=(value) ⇒ Object (writeonly)

Sets the attribute s

Parameters:

  • the value to set the attribute s to.



3
4
5
# File 'lib/Xomponent/Style.rb', line 3

def s=(value)
  @s = value
end

Instance Method Details

#add(selector, styles) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/Xomponent/Style.rb', line 12

def add(selector, styles)
  styles_str = styles.map do |name, value|
    "#{name}:#{value}"
  end.join(';')

  @s += "#{selector}{#{styles_str}}"
end

#renderObject



20
21
22
# File 'lib/Xomponent/Style.rb', line 20

def render
  @s
end

#reset!Object



8
9
10
# File 'lib/Xomponent/Style.rb', line 8

def reset!
  @s = "body{margin:0;font-family:sans-serif}"
end