Class: RVM::Functions::Regmatch
Class Method Summary
collapse
Methods inherited from Function
call, execargs, method_missing, method_missing_old_functions
Methods included from Plugin
#helper, #included, #plugin_host, #plugin_id, #register_for
Class Method Details
.data_type ⇒ Object
27
28
29
|
# File 'lib/rvm/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/rvm/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 RVM::Classes[:error].new(1,"INVALID REGULAR EXPRESSION")
end
if regexp.match(str)
RVM::Classes[:boolean].new(true)
else
RVM::Classes[:boolean].new(false)
end
else
RVM::Classes[:error].new(1,"FUNCTION (#{self.class.to_s}) EXPECTS 2 ARGUMENTS BUT GOT #{params.length}")
end
end
|
.signature ⇒ Object
23
24
25
|
# File 'lib/rvm/functions/string/regmatch.rb', line 23
def signature
[:string, :string] end
|