Class: Glimmer::CSS::RuleSet
- Inherits:
-
Object
- Object
- Glimmer::CSS::RuleSet
- Defined in:
- lib/glimmer/css/rule_set.rb
Instance Attribute Summary collapse
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
-
#selector ⇒ Object
readonly
Returns the value of attribute selector.
Instance Method Summary collapse
- #add_property(keyword, *args) ⇒ Object
-
#initialize(selector) ⇒ RuleSet
constructor
A new instance of RuleSet.
- #to_css ⇒ Object (also: #to_s)
Constructor Details
#initialize(selector) ⇒ RuleSet
Returns a new instance of RuleSet.
6 7 8 9 |
# File 'lib/glimmer/css/rule_set.rb', line 6 def initialize(selector) @selector = selector @properties = {} end |
Instance Attribute Details
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
4 5 6 |
# File 'lib/glimmer/css/rule_set.rb', line 4 def properties @properties end |
#selector ⇒ Object (readonly)
Returns the value of attribute selector.
4 5 6 |
# File 'lib/glimmer/css/rule_set.rb', line 4 def selector @selector end |
Instance Method Details
#add_property(keyword, *args) ⇒ Object
11 12 13 14 |
# File 'lib/glimmer/css/rule_set.rb', line 11 def add_property(keyword, *args) keyword = keyword.to_s.downcase.gsub('_', '-') @properties[keyword] = args.first end |
#to_css ⇒ Object Also known as: to_s
16 17 18 19 20 21 22 |
# File 'lib/glimmer/css/rule_set.rb', line 16 def to_css css = "#{@selector} {\n" @properties.each do |name, value| css << " #{name}: #{value};\n" end css << "}" end |