1
###########################################################################/**
2
# @RdocClass RspIfDirective
3
# @alias RspElseDirective
4
# @alias RspEndifDirective
5
# @alias RspIfdefDirective
6
# @alias RspIfndefDirective
7
# @alias RspIfeqDirective
8
# @alias RspIfneqDirective
9
#
10
# @title "The RspIfDirective class"
11
#
12
# \description{
13
#  @classhierarchy
14
#
15
#  An RspIfDirective is an @see "RspDirective" that will include or
16
#  exclude all @see "RspConstruct":s until the next @see "RspEndifDirective"
17
#  based on the preprocessing value of the particular if clause.
18
#  Inclusion/exclusion can be reversed via an @see "RspElseDirective".
19
# }
20
#
21
# @synopsis
22
#
23
# \arguments{
24
#   \item{value}{A @character string.}
25
#   \item{...}{Arguments passed to the constructor of @see "RspDirective".}
26
# }
27
#
28
# \section{Fields and Methods}{
29
#  @allmethods
30
# }
31
#
32
# @author
33
#
34
# @keyword internal
35
#*/###########################################################################
36
setConstructorS3("RspIfDirective", function(value="if", ...) {
37 1
  this <- extend(RspDirective(value, ...), "RspIfDirective")
38 1
  if (!missing(value)) {
39 1
    requireAttributes(this, c("test"))
40

41
    # Test aliases
42 1
    test <- getAttribute(this, "test")
43 1
    map <- c(
44 1
      "==" = "equal-to",
45 1
      "!=" = "not-equal-to",
46 1
      ">"  = "greater-than",
47 1
      ">=" = "greater-than-or-equal-to",
48 1
      "<"  = "less-than",
49 1
      "<=" = "less-than-or-equal-to"
50
    )
51 1
    testA <- map[test]
52 1
    if (!is.na(testA)) {
53 0
      this <- setAttribute(this, "test", testA)
54
    }
55
  }
56 1
  this
57
})
58

59
setConstructorS3("RspElseDirective", function(value="else", ...) {
60 1
  extend(RspDirective(value, ...), "RspElseDirective")
61
})
62

63
setConstructorS3("RspEndifDirective", function(value="endif", ...) {
64 1
  extend(RspDirective(value, ...), "RspEndifDirective")
65
})
66

67

68
# Alias: <%@ifeq ...%> => <%@if test="equals" ...%>
69
setConstructorS3("RspIfeqDirective", function(value="if", ...) {
70 1
  extend(RspIfDirective(value, test="equal-to", ...), "RspIfeqDirective")
71
})
72

73
# Alias: <%@ifneq ...%> => <%@if test="equals" negate="TRUE", ...%>
74
setConstructorS3("RspIfneqDirective", function(value="if", ...) {
75 1
  this <- extend(RspIfeqDirective(value, ...), "RspIfneqDirective")
76
  # Negate the 'test' result
77 1
  negate <- !getAttribute(this, "negate", FALSE)
78 1
  this <- setAttribute(this, "negate", negate)
79 1
  this
80
})
81

82

83
# Alias: <%@ifdef ...%> => <%@if test="exists" ...%>
84
setConstructorS3("RspIfdefDirective", function(value="if", ...) {
85 1
  extend(RspIfDirective(value, test="exists", ...), "RspIfeqDirective")
86
})
87

88
# Alias: <%@ifndef ...%> => <%@if test="exists" negate="TRUE", ...%>
89
setConstructorS3("RspIfndefDirective", function(value="if", ...) {
90 1
  this <- extend(RspIfdefDirective(value, ...), "RspIfneqDirective")
91
  # Negate the 'test' result
92 1
  negate <- !getAttribute(this, "negate", FALSE)
93 1
  this <- setAttribute(this, "negate", negate)
94 1
  this
95
})

Read our documentation on viewing source code .

Loading