Class: WebFunction::Argument

Inherits:
Object
  • Object
show all
Defined in:
lib/web_function/argument.rb

Overview

# Argument

Arguments used by Web Function endpoints to define its input parameters.

See the [arguments section] on the Web Function website for more details.

[0]: webfunction.org/package#arguments

Instance Method Summary collapse

Constructor Details

#initialize(argument) ⇒ Argument

Returns a new instance of Argument.



13
14
15
# File 'lib/web_function/argument.rb', line 13

def initialize(argument)
  @argument = argument
end

Instance Method Details

#choicesArray

## Choices

An array specifying the exact, case-sensitive values that are permitted for this argument. Each value in the choices array must conform to the data type specified in the argument’s type key.

Note that if the argument type is array, choices may contain strings or numbers representing the allowed values that can be included in the array.

Returns:

  • (Array)


79
80
81
# File 'lib/web_function/argument.rb', line 79

def choices
  [*@argument["choices"]]
end

#docsString

## Docs

Description of the argument. It must be formatted as markdown.

Returns:

  • (String)


103
104
105
# File 'lib/web_function/argument.rb', line 103

def docs
  @argument["docs"].to_s
end

#flagsArray<String>

## Flags

List of argument flags. See the [available flags section] on the Web Function website for a complete list of flags available at the argument level.

[2]: webfunction.org/package#available-flags

Returns:

  • (Array<String>)


93
94
95
# File 'lib/web_function/argument.rb', line 93

def flags
  [*@argument["flags"]].map { |flag| flag.to_s }
end

#groupString

## Group

A name used to categorize or group similar arguments together. This should be used by documentation tools to organize related arguments.

Returns:

  • (String)


64
65
66
# File 'lib/web_function/argument.rb', line 64

def group
  @argument["group"]
end

#hintString

## Hint

The hint of the argument

See the [hints section] on the Web Function website for the full list of possible hints.

[1]: webfunction.org/package#hints

Returns:

  • (String)


53
54
55
# File 'lib/web_function/argument.rb', line 53

def hint
  @argument["hint"]
end

#nameString

## Name

The name of the argument.

Returns:

  • (String)


23
24
25
# File 'lib/web_function/argument.rb', line 23

def name
  @argument["name"]
end

#typeString

## Type

The type of the argument. It must be one of:

- object
- array
- string
- number
- boolean

Returns:

  • (String)


38
39
40
# File 'lib/web_function/argument.rb', line 38

def type
  @argument["type"]
end