Sha256: ad67141bc888f6fba52188d7db4621b0d8b74ab4380379533da5cedf379f8ce1

Contents?: true

Size: 531 Bytes

Versions: 14

Compression:

Stored size: 531 Bytes

Contents

module Glimmer
  module CSS
    class Rule
      attr_reader :selector, :properties

      def initialize(selector)
        @selector = selector
        @properties = {}
      end

      def add_property(keyword, *args)
        keyword = keyword.to_s.downcase.gsub('_', '-')
        @properties[keyword] = args.first
      end

      def to_css
        css = "#{@selector}{"
        css << @properties.map { |name, value| "#{name}:#{value}" }.join(';')
        css << "}"
      end

      alias to_s to_css      
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
glimmer-dsl-css-0.2.0 lib/glimmer/css/rule.rb
glimmer-dsl-css-0.1.0 lib/glimmer/css/rule.rb
glimmer-0.8.2 lib/glimmer/css/rule.rb
glimmer-0.8.1 lib/glimmer/css/rule.rb
glimmer-0.8.0 lib/glimmer/css/rule.rb
glimmer-0.7.8 lib/glimmer/css/rule.rb
glimmer-0.7.7 lib/glimmer/css/rule.rb
glimmer-0.7.6 lib/glimmer/css/rule.rb
glimmer-0.7.5 lib/glimmer/css/rule.rb
glimmer-0.7.4 lib/glimmer/css/rule.rb
glimmer-0.7.3 lib/glimmer/css/rule.rb
glimmer-0.7.2 lib/glimmer/css/rule.rb
glimmer-0.7.1 lib/glimmer/css/rule.rb
glimmer-0.7.0 lib/glimmer/css/rule.rb