Created
July 7, 2011 09:58
-
-
Save neilmanuell/1069216 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.osflash.statemachine.supporting { | |
public function injectThis( value:String):ITokenInjector { | |
return new InjectTokenIntoString( value ); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.osflash.statemachine.supporting { | |
public class InjectTokenIntoString implements ITokenInjector { | |
private var _value:String; | |
public function InjectTokenIntoString( value:String ) { | |
_value = value; | |
} | |
public function withThis( keyword:String, replace:* ):ITokenInjector { | |
inject( keyword, replace ); | |
return this; | |
} | |
public function finallyWith( keyword:String, replace:* ):String { | |
inject( keyword, replace ); | |
return _value; | |
} | |
private function inject( keyword:String, replace:* ):void { | |
const regexp:RegExp = new RegExp( "\\$\\{(" + keyword + ")\\}", "g" ); | |
_value = _value.replace( regexp, replace.toString() ); | |
} | |
public function toString():String { | |
return _value; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package revisual.utils { | |
public interface ITokenInjector { | |
function withThis( keyword:String, replace:* ):ITokenInjector | |
function finallyWith( keyword:String, replace:* ):String | |
function toString():String; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment