Class: AmberVM::Functions::Regmatch
- Defined in:
- lib/amber/functions/string/regmatch.rb
Class Method Summary collapse
Methods inherited from Function
call, execargs, method_missing
Methods included from Plugin
#helper, #included, #plugin_host, #plugin_id, #register_for
Class Method Details
.data_type ⇒ Object
27 28 29 |
# File 'lib/amber/functions/string/regmatch.rb', line 27 def data_type :boolean end |
.execute(params, env) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/amber/functions/string/regmatch.rb', line 5 def execute params, env if params.length == 2 str = params[0] regexp = params[1].to_s begin regexp = Regexp.new(regexp) rescue return AmberVM::Classes[:error].new(1,"INVALID REGULAR EXPRESSION") end if regexp.match(str) AmberVM::Classes::Boolean.new(true) else AmberVM::Classes::Boolean.new(false) end else AmberVM::Classes[:error].new(1,"FUNCTION (#{self.class.to_s}) EXPECTS 2 ARGUMENTS BUT GOT #{params.length}") end end |