Top Level Namespace

Defined Under Namespace

Modules: Distil, Kernel Classes: Browser, Configurable, FirefoxBrowser, IEBrowser, SafariBrowser, ValidationError

Instance Method Summary collapse

Instance Method Details

#class_attr(*rest) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/distil.rb', line 9

def class_attr(*rest)
  rest.each { |name|
    class_eval %(
          def self.#{name}(*rest)
            if (rest.length>0)
              @#{name}= rest[0]
            else
              @#{name} || (superclass.respond_to?(name) ? superclass.#{name} : nil)
            end
          end
          def self.#{name}=(value)
            @#{name}= value
          end
          def #{name}
            @#{name} || self.class.#{name}
          end
          def #{name}=(value)
            @#{name}=value
          end
        )
  }
end

#exist?(path, file) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/distil.rb', line 32

def exist?(path, file)
  File.file?(File.join(path, file))
end

#replace_tokens(string, params) ⇒ Object

Do a simple token substitution. Tokens begin and end with @.



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/distil.rb', line 51

def replace_tokens(string, params)
	return string.gsub(/(\n[\t ]*)?@([^@ \t\r\n]*)@/) { |m|
		key= $2
		ws= $1
		value= params[key]||m;
		if (ws && ws.length)
			ws + value.split("\n").join(ws);
		else
			value
		end
	}
end