#' An S4 class to represent a file
#'
#' @slot path The path of the file in the host
setClass (
Class = "File",
representation = representation(
path = "character"
),
validity = function(object){
cat("~~~ File: inspector ~~~ \n")
type <- object@path
if(length(object@path) != 1){
stop ("[File: validation] Only one path allowed")
}else{}
return(TRUE)
}
)
#*******************************************************
#CONSTRUCTOR
setMethod (
f="initialize",
signature="File",
definition=function(.Object,path){
#cat ("~~~~~ File: initializator ~~~~~ \n")
if(!missing(path)){
.Object@path <- path
validObject(.Object)# call of the inspector
}else{
.Object@path <- character(0)
}
return(.Object)
}
)
#CONSTRUCTOR (USER FRIENDLY)
file <- function(path){
cat ("~~~~~ File: constructor ~~~~~ \n")
new (Class="File", path = path)
}
#*******************************************************
#ACCESSORS
setGeneric("getPath",function(object){standardGeneric ("getPath")})
setMethod("getPath","File",
function(object){
return(object@path)
}
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.