-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathgeoflow_format.R
80 lines (73 loc) · 1.95 KB
/
geoflow_format.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#' geoflow_format
#'
#' @docType class
#' @importFrom R6 R6Class
#' @export
#'
#' @name geoflow_format
#' @title Geoflow format class
#' @description This class models a format
#' @keywords format mime mimetype
#' @return Object of \code{\link{R6Class}} for modelling a format
#' @format \code{\link{R6Class}} object.
#'
#' @examples
#' \dontrun{
#' format <- geoflow_format$new()
#' format$setKey("distribution")
#' format$setName("text/csv")
#' format$setUri("https://www.iana.org/assignments/media-types/text/csv")
#' format$setDescription("CSV format")
#' }
#'
#' @author Emmanuel Blondel <emmanuel.blondel1@@gmail.com>
#'
geoflow_format <- R6Class("geoflow_format",
public = list(
#'@field key format key
key = NULL,
#'@field name key name
name = NULL,
#'@field uri key URI
uri = NULL,
#'@field description key description
description = NULL,
#'@description Initializes a \link{geoflow_format}
#'@param str character string to initialize object using key-based syntax
initialize = function(str = NULL){
if(!is.null(str)){
format_kvp <- extract_kvp(str)
key <- format_kvp$key
self$setKey(key)
value = format_kvp$values[[1]]
uri <- attr(value, "uri")
description <- attr(value, "description")
attr(value, "uri") <- NULL
attr(value, "description") <- NULL
self$setUri(uri)
self$setName(value)
self$setDescription(description)
}
},
#'@description Sets format key
#'@param key key
setKey = function(key){
self$key <- key
},
#'@description Sets format name
#'@param name name
setName = function(name){
self$name <- name
},
#'@description Sets format URI
#'@param uri URI
setUri = function(uri){
self$uri <- uri
},
#'@description Sets format description
#'@param description description
setDescription = function(description){
self$description <- description
}
)
)