Class: MODL::Parser::StandardMethods
- Inherits:
-
Object
- Object
- MODL::Parser::StandardMethods
- Defined in:
- lib/modl/parser/modl_method.rb
Class Method Summary collapse
-
.extract_params(str) ⇒ Object
Extract the method parameter.
-
.get_subst_parts(s) ⇒ Object
Extract the method parameters.
- .run_method(m, str) ⇒ Object
Class Method Details
.extract_params(str) ⇒ Object
Extract the method parameter
126 127 128 129 |
# File 'lib/modl/parser/modl_method.rb', line 126 def self.extract_params(str) # should be of the form .r(s1,s2) Sutil.between(str, '(', ')') end |
.get_subst_parts(s) ⇒ Object
Extract the method parameters
117 118 119 120 121 122 123 |
# File 'lib/modl/parser/modl_method.rb', line 117 def self.get_subst_parts(s) # should be of the form .r(s1,s2) result = extract_params(s).split(',') result[0] = '' if result.length.zero? || result[0].nil? result[1] = '' if result.length == 1 || result[1].nil? result end |
.run_method(m, str) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/modl/parser/modl_method.rb', line 88 def self.run_method(m, str) case m[0] when 'u' str.upcase when 'd' str.downcase when 'i' str.split.map(&:capitalize) * ' ' when 's' split = str.split split[0].capitalize! split.join(' ') when 'e' CGI.escape(str) when 'r' s1, s2 = get_subst_parts m str.sub(s1, s2) when 't' s1 = extract_params m i = str.index(s1) Sutil.head(str, i) when 'p' Punycode.decode(str) else str + '.' + m end end |