Top Level Namespace
Defined Under Namespace
Modules: Distil, Kernel Classes: Browser, Configurable, FirefoxBrowser, IEBrowser, SafariBrowser, String, ValidationError
Instance Method Summary collapse
- #class_attr(*rest) ⇒ Object
- #exist?(path, file) ⇒ Boolean
-
#replace_tokens(string, params) ⇒ Object
Do a simple token substitution.
Instance Method Details
#class_attr(*rest) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/distil.rb', line 10 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
33 34 35 |
# File 'lib/distil.rb', line 33 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 @.
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/distil.rb', line 64 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 |