| URL {sched} | R Documentation |
URL class.
Description
URL class.
URL class.
Details
This class represents a URL object that can be used in requests. It handles parameters as a list, making it easy to build URLs for contacting web services.
Methods
Public methods
Method new()
Initializer.
Usage
URL$new(url = character(), params = character(), chomp_extra_slashes = TRUE)
Arguments
urlThe URL to access, as a character vector.
paramsThe list of parameters to append to this URL. If it is an unnamed list or vector, the values will be converted to strings and concatenated with the
&separator. If it is a named list or vector, the names will be used as keys as in "name1=value1&name2=value2&...".chomp_extra_slashesIf set to TRUE, then slashes at the end and the beginning of each element of the url vector parameter will be removed before proper concatenation.
Returns
Nothing.
Examples
# Create a URL object
url <- sched::URL$new("https://www.my.server/", c(param1=12,
param2='abc'))
Method getDomain()
Etracts the domain name from the URL.
Usage
URL$getDomain()
Returns
The domain.
Examples
# Create a URL object
url <- sched::URL$new("https://www.my.server/",
c(param1=12, param2='abc'))
# Extract the domain name
print(url$getDomain())
Method setUrl()
Sets the base URL string.
Usage
URL$setUrl(url)
Arguments
urlThe base URL string.
Returns
Nothing.
Examples
# Create an empty URL object
url <- sched::URL$new()
# Set the URL
url$setUrl('https://www.my.server/')
# Convert the URL to a string
print(url$toString())
Method setParam()
Sets a parameter.
Usage
URL$setParam(key, value)
Arguments
keyThe parameter name.
valueThe value of the parameter.
Returns
Nothing.
Examples
# Create an URL object
url <- sched::URL$new('https://www.my.server/')
# Set a parameter
url$setParam('a', 12)
# Convert the URL to a string
print(url$toString())
Method print()
Displays information about this instance.
Usage
URL$print()
Returns
self as invisible.
Examples
# Create an URL object
url <- sched::URL$new('https://www.my.server/')
# Print the URL object
print(url)
Method toString()
Gets the URL as a string representation.
Usage
URL$toString(encode = TRUE)
Arguments
encodeIf set to TRUE, then encodes the URL.
Returns
The URL as a string, with all parameters and values set.
Examples
# Create an URL object
url <- sched::URL$new('https://www.my.server/', c(a=12))
# Convert the URL to a string
print(url$toString())
Method clone()
The objects of this class are cloneable with this method.
Usage
URL$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Examples
# Create a URL object from a base URL string and a list of parameters
base.url <- c("https://www.uniprot.org", "uniprot")
params <- c(query="reviewed:yes+AND+organism:9606",
columns='id,entry name,protein names',
format="tab")
url <- sched::URL$new(url=base.url, params=params)
# Print the URL converted to a string
print(url$toString())
## ------------------------------------------------
## Method `URL$new`
## ------------------------------------------------
# Create a URL object
url <- sched::URL$new("https://www.my.server/", c(param1=12,
param2='abc'))
## ------------------------------------------------
## Method `URL$getDomain`
## ------------------------------------------------
# Create a URL object
url <- sched::URL$new("https://www.my.server/",
c(param1=12, param2='abc'))
# Extract the domain name
print(url$getDomain())
## ------------------------------------------------
## Method `URL$setUrl`
## ------------------------------------------------
# Create an empty URL object
url <- sched::URL$new()
# Set the URL
url$setUrl('https://www.my.server/')
# Convert the URL to a string
print(url$toString())
## ------------------------------------------------
## Method `URL$setParam`
## ------------------------------------------------
# Create an URL object
url <- sched::URL$new('https://www.my.server/')
# Set a parameter
url$setParam('a', 12)
# Convert the URL to a string
print(url$toString())
## ------------------------------------------------
## Method `URL$print`
## ------------------------------------------------
# Create an URL object
url <- sched::URL$new('https://www.my.server/')
# Print the URL object
print(url)
## ------------------------------------------------
## Method `URL$toString`
## ------------------------------------------------
# Create an URL object
url <- sched::URL$new('https://www.my.server/', c(a=12))
# Convert the URL to a string
print(url$toString())