lib/beautiful-css/rule.rb in beautiful-css-0.0.1 vs lib/beautiful-css/rule.rb in beautiful-css-0.0.3

- old
+ new

@@ -1,27 +1,15 @@ - module BeautifulCss - class Rule - def initialize(str) - @body = str - end - def selectors - @body.match(/[^{]*/).to_s.split(/,/).map{|s| s.strip}.select{|s| !s.empty? } - end + attr_accessor :selector, :prop, :value - def props - begin - p = @body.match(/\{([^}]*)/)[1].split(';').select{|s| !s.strip.empty? } - p.map{|s| "{ " + s.strip + " }"} - rescue - [] - end + def initialize(selector, prop, value) + @selector, @prop, @value = selector.strip, prop.strip, value.strip end - def body - @body + def to_s + @selector + "\n" + "{ #{prop}:#{value} }" end end end