Browse Source

Added String >> asRegexp (see issue #319)

Nicolas Petton 12 years ago
parent
commit
c0cffae40f
3 changed files with 35 additions and 0 deletions
  1. 13 0
      js/Kernel-Collections.deploy.js
  2. 18 0
      js/Kernel-Collections.js
  3. 4 0
      st/Kernel-Collections.st

+ 13 - 0
js/Kernel-Collections.deploy.js

@@ -2323,6 +2323,19 @@ return self}, function($ctx1) {$ctx1.fill(self,"asNumber",{}, smalltalk.String)}
 }),
 smalltalk.String);
 
+smalltalk.addMethod(
+"_asRegexp",
+smalltalk.method({
+selector: "asRegexp",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
var $1;
+$1=_st((smalltalk.RegularExpression || RegularExpression))._fromString_(self);
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"asRegexp",{}, smalltalk.String)})}
+}),
+smalltalk.String);
+
 smalltalk.addMethod(
 "_asSelector",
 smalltalk.method({

+ 18 - 0
js/Kernel-Collections.js

@@ -3114,6 +3114,24 @@ referencedClasses: []
 }),
 smalltalk.String);
 
+smalltalk.addMethod(
+"_asRegexp",
+smalltalk.method({
+selector: "asRegexp",
+category: 'converting',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
var $1;
+$1=_st((smalltalk.RegularExpression || RegularExpression))._fromString_(self);
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"asRegexp",{}, smalltalk.String)})},
+args: [],
+source: "asRegexp\x0a\x09^ RegularExpression fromString: self",
+messageSends: ["fromString:"],
+referencedClasses: ["RegularExpression"]
+}),
+smalltalk.String);
+
 smalltalk.addMethod(
 "_asSelector",
 smalltalk.method({

+ 4 - 0
st/Kernel-Collections.st

@@ -1042,6 +1042,10 @@ asNumber
 	<return Number(self)>
 !
 
+asRegexp
+	^ RegularExpression fromString: self
+!
+
 asSelector
 	<return smalltalk.selector(self)>
 !