From 9b615b0d771d04c7a98e1b9ada65f996b8b50bd1 Mon Sep 17 00:00:00 2001 From: Sebastian Kopf Date: Thu, 24 Apr 2014 19:59:28 -0700 Subject: [PATCH] add name to exported generic methods --- NAMESPACE | 1 + R/show.R | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/NAMESPACE b/NAMESPACE index bb9d125..2a72254 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -32,5 +32,6 @@ exportMethods(as.weighted_value) exportMethods(fractionate) exportMethods(label) exportMethods(mass_balance) +exportMethods(name) exportMethods(shift_reference) exportMethods(weight) diff --git a/R/show.R b/R/show.R index 136b7f2..017f0f9 100644 --- a/R/show.R +++ b/R/show.R @@ -43,7 +43,13 @@ ratio_name <- function(text1, text2, spacer = "", top = "", bottom = "") { #' Get the name of an isotopic data object #' @export +#' @method name setGeneric("name", function(object) standardGeneric("name")) + +#' @export +#' @method name +setMethod("name", "ANY", function(object) stop("the name() function is not defined for objects of type ", class(object))) + setMethod("name", "Isoval", function(object) object@isoname) setMethod("name", "Ratio", function(object) ratio_name("R", "", spacer = " ", object@isoname, object@major)) setMethod("name", "Abundance", function(object) ratio_name("F", object@isoname)) @@ -56,7 +62,6 @@ setMethod("name", "Epsilon", function(object) { setMethod("name", "Delta", function(object) paste("δ", object@isoname, sep = "")) #' Get the units of an isotope data object -#' @export setGeneric("unit", function(object) standardGeneric("unit")) setMethod("unit", "Isoval", function(object) "") setMethod("unit", "Epsilon", function(object) if(object@permil) "‰" else "")