Parent

Files

Markaby::CssProxy

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.

Public Class Methods

new(builder, stream, sym) click to toggle source
    # File lib/markaby/cssproxy.rb, line 7
 7:     def initialize(builder, stream, sym)
 8:       @builder = builder
 9:       @stream  = stream
10:       @sym     = sym
11:       @attrs   = {}
12: 
13:       @original_stream_length = @stream.length
14: 
15:       @builder.tag! sym
16:     end

Public Instance Methods

respond_to?(sym, include_private = false) click to toggle source
    # File lib/markaby/cssproxy.rb, line 18
18:     def respond_to?(sym, include_private = false)
19:       include_private || !private_methods.map { |m| m.to_sym }.include?(sym.to_sym) ? true : false
20:     end

Private Instance Methods

method_missing(id_or_class, *args, &block) click to toggle source

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

    # File lib/markaby/cssproxy.rb, line 26
26:     def method_missing(id_or_class, *args, &block)
27:       if id_or_class.to_s =~ /(.*)!$/
28:         @attrs[:id] = $1
29:       else
30:         id = id_or_class
31:         @attrs[:class] = @attrs[:class] ? "#{@attrs[:class]} #{id}".strip : id
32:       end
33: 
34:       unless args.empty?
35:         if args.last.respond_to? :to_hash
36:           @attrs.merge! args.pop.to_hash
37:         end
38:       end
39: 
40:       args.push(@attrs)
41: 
42:       while @stream.length > @original_stream_length
43:         @stream.pop
44:       end
45: 
46:       if block
47:         @builder.tag! @sym, *args, &block
48:       else
49:         @builder.tag! @sym, *args
50:       end
51: 
52:       self
53:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.