Class: Hpricot::CssProxy

Class | Hpricot::CssProxy
In: | lib/hpricot/builder.rb
Parent: | BlankSlate

Class used by Markaby::Builder to store element options. Methods called against the CssProxy object are added as element classes or IDs.

See the README for examples.

### Methods

method_missing new

### Public Class methods

new(builder, sym)

Creates a CssProxy object.

[Source]

    # File lib/hpricot/builder.rb, line 194
        def initialize(builder, sym)
          @builder, @sym, @attrs = builder, sym, {}
        end

### Public Instance methods

method_missing(id_or_class, *args, &block)

Adds attributes to an element. Bang methods set the :id attribute. Other methods add to the :class attribute.

[Source]

    # File lib/hpricot/builder.rb, line 200
        def method_missing(id_or_class, *args, &block)
          if (idc = id_or_class.to_s) =~ /!$/
            @attrs[:id] = $`
          else
            @attrs[:class] = @attrs[:class].nil? ? idc : "#{@attrs[:class]} #{idc}".strip
          end

          if block or args.any?
            args.push(@attrs)
            return @builder.tag!(@sym, *args, &block)
          end

          return self
        end

[Validate]