[Ruler-commits] r60 - pkg/ruleR/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Oct 11 09:36:42 CEST 2012


Author: merysionek
Date: 2012-10-11 09:36:41 +0200 (Thu, 11 Oct 2012)
New Revision: 60

Modified:
   pkg/ruleR/R/ruleR_upgraded_final.R
Log:
added a prototype objects (in definition of class) in order to avoid entering new("IdenSingleRule") as slots

Modified: pkg/ruleR/R/ruleR_upgraded_final.R
===================================================================
--- pkg/ruleR/R/ruleR_upgraded_final.R	2012-10-10 20:32:03 UTC (rev 59)
+++ pkg/ruleR/R/ruleR_upgraded_final.R	2012-10-11 07:36:41 UTC (rev 60)
@@ -36,6 +36,7 @@
 setClass("AddConstSingleRule",
          contains="SingleRule",
          representation(constantVal="numeric"),
+         prototype(previousRule=new("IdenSingleRule")),
          S3methods=TRUE)
 
 setMethod("calculateSpecific",signature(x="AddConstSingleRule", y="numeric"),
@@ -49,6 +50,7 @@
 setClass("MultConstSingleRule",
          contains="SingleRule",
          representation(constantVal="numeric"),
+         prototype(previousRule=new("IdenSingleRule")),
          S3methods=TRUE)
 
 setMethod("calculateSpecific",signature(x="MultConstSingleRule", y="numeric"),
@@ -71,7 +73,11 @@
 
 
 
-setClass("DigSumSingleRule", contains="SingleRule",S3methods=TRUE)
+setClass("DigSumSingleRule",
+         contains="SingleRule",
+         representation(constantVal="numeric"),
+         prototype(previousRule=new("IdenSingleRule")),
+         S3methods=TRUE)
 
 setMethod("calculateSpecific",signature(x="DigSumSingleRule",y="numeric"),
           function(x,y){
@@ -120,23 +126,30 @@
 # nextSingle - operation to be executed at the result of function DoubleRule
 
 
-setClass("DoubleRule", representation = representation(firstRule="SingleRule", secondRule="SingleRule",nextSingle="SingleRule"),
+setClass("DoubleRule", 
+         representation = representation(firstRule="SingleRule", secondRule="SingleRule",nextSingle="SingleRule"),
+         prototype(firstRule=new("IdenSingleRule"),secondRule=new("IdenSingleRule"),nextSingle=new("IdenSingleRule")),
          S3methods=TRUE)
 
 
 
 #[1] ADD TWO PREVIOUS EXPRESSIONS
 
-setClass("AddDoubleRule", contains="DoubleRule",S3methods=TRUE)
+setClass("AddDoubleRule",
+         contains="DoubleRule",
+          S3methods=TRUE)
 
-setMethod("calculateSpecific",signature(x="AddDoubleRule", y="numeric", z="numeric"),
+setMethod("calculateSpecific",
+          signature(x="AddDoubleRule", y="numeric", z="numeric"),
           function(x,y,z){
             return(y+z)
           })
 
 #[2] MULTIPLY TWO PREVIOUS EXPRESSIONS 
 
-setClass("MultDoubleRule",contains="DoubleRule",S3methods=TRUE)
+setClass("MultDoubleRule",
+         contains="DoubleRule",         
+         S3methods=TRUE)
 
 
 setMethod("calculateSpecific",signature(x="MultDoubleRule", y="numeric", z="numeric"),
@@ -460,12 +473,15 @@
 
 # 'range' of constant value user want to use (it can be a vector (ex. sequence with min value, max value and step)) 
 
+setClassUnion(name="Rule", members=c("SingleRule","DoubleRule"))
+setClassUnion(name="vecORnull", members=c("vector","NULL"))
+
+
 setClass("DictionaryRule",representation(rule="Rule",range="vecORnull"),S3methods=TRUE)
 
 
-setClassUnion(name="Rule", members=c("SingleRule","DoubleRule"))
-setClassUnion(name="vecORnull", members=c("vector","NULL"))
 
+
 #make a list of objects of class DirectRules and send the list to createItems function and name it as you wish
 
 #'range' for constant Value parameter// can be a vector ie. seq(3,5,by=.1) or a single numeric value



More information about the Ruler-commits mailing list