Class: RedSnow::Parameter
- Inherits:
-
NamedBlueprintNode
- Object
- BlueprintNode
- NamedBlueprintNode
- RedSnow::Parameter
- Defined in:
- lib/redsnow/blueprint.rb
Overview
URI parameter Blueprint AST node
represents one 'parameters section' parameter
Instance Attribute Summary collapse
-
#default_value ⇒ String
default value of the parameter or nil This is a value used when the parameter is ommited in the request.
-
#example_value ⇒ String
example value of the parameter or nil.
-
#type ⇒ String
an arbitrary type of the parameter or nil.
-
#use ⇒ Symbol
parameter necessity flag, ‘:required`, `:optional` or :undefined Where `:undefined` implies `:required` according to the API Blueprint Specification.
-
#values ⇒ Array<String>
an enumeration of possible parameter values.
Attributes inherited from NamedBlueprintNode
Instance Method Summary collapse
-
#initialize(parameter) ⇒ Parameter
constructor
A new instance of Parameter.
Methods inherited from NamedBlueprintNode
Constructor Details
#initialize(parameter) ⇒ Parameter
Returns a new instance of Parameter.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/redsnow/blueprint.rb', line 143 def initialize(parameter) @name = parameter.fetch('name', '') @description = parameter.fetch('description', '') @type = parameter.fetch('type', '') case parameter['required'] when true @use = :required when false @use = :optional else @use = :undefined end @default_value = parameter.fetch('default', nil) @example_value = parameter.fetch('example', nil) @values = [] parameter.key?('values') && parameter['values'].each do |value| @values << value['value'] end end |
Instance Attribute Details
#default_value ⇒ String
default value of the parameter or nil This is a value used when the parameter is ommited in the request.
135 136 137 |
# File 'lib/redsnow/blueprint.rb', line 135 def default_value @default_value end |
#example_value ⇒ String
example value of the parameter or nil
135 136 137 |
# File 'lib/redsnow/blueprint.rb', line 135 def example_value @example_value end |
#type ⇒ String
an arbitrary type of the parameter or nil
135 136 137 |
# File 'lib/redsnow/blueprint.rb', line 135 def type @type end |
#use ⇒ Symbol
parameter necessity flag, ‘:required`, `:optional` or :undefined Where `:undefined` implies `:required` according to the API Blueprint Specification
135 136 137 |
# File 'lib/redsnow/blueprint.rb', line 135 def use @use end |
#values ⇒ Array<String>
an enumeration of possible parameter values
135 136 137 |
# File 'lib/redsnow/blueprint.rb', line 135 def values @values end |