ronin/scripts/command.js
2016-11-16 15:51:30 -08:00

83 lines
1.9 KiB
JavaScript

function Command(content)
{
this.content = content;
this.any = function()
{
if(this.content.join() === ""){ return null; }
return new Any(this.content);
}
this.rect = function()
{
for (i = 0; i < this.content.length; i++) {
if(this.content[i].indexOf("x") >= 0){ return new Rect(this.content[i]); }
}
return null;
}
this.position = function()
{
for (i = 0; i < this.content.length; i++) {
if(this.content[i].indexOf(",") >= 0){ return new Position(this.content[i]); }
}
return null;
}
this.color = function()
{
for (i = 0; i < this.content.length; i++) {
if(this.content[i].indexOf("#") >= 0){ return new Color(this.content[i]); }
}
return null;
}
this.filepath = function()
{
for (i = 0; i < this.content.length; i++) {
if(this.content[i].indexOf("/") >= 0){ return new Filepath(this.content[i]); }
}
return null;
}
this.value = function()
{
for (i = 0; i < this.content.length; i++) {
var test = /[^$\-\d]/.test(this.content[i]);
if(!test && this.content[i] !== ""){ return new Value(this.content[i]); }
}
return null;
}
this.range = function()
{
for (i = 0; i < this.content.length; i++) {
if(this.content[i].indexOf("..") >= 0){ return new Range(this.content[i]); }
}
return null;
}
this.bang = function()
{
for (i = 0; i < this.content.length; i++) {
if(this.content[i].indexOf("!") >= 0){ return new Bang(); }
}
return null;
}
this.angle = function()
{
for (i = 0; i < this.content.length; i++) {
if(this.content[i].indexOf("'") >= 0){ return new Angle(this.content[i]); }
}
return null;
}
this.variable = function(name)
{
for (i = 0; i < this.content.length; i++) {
if(this.content[i].indexOf(name+":") >= 0){ return Variable(this.content[i]); }
}
return null;
}
}