Class: RedSnow::Sourcemap::Parameter

Inherits:
NamedNode show all
Defined in:
lib/redsnow/sourcemap.rb

Overview

Parameter source map node

Instance Attribute Summary collapse

Attributes inherited from NamedNode

#description, #name

Attributes inherited from Node

#collection

Instance Method Summary collapse

Constructor Details

#initialize(sourcemap) ⇒ Parameter

Returns a new instance of Parameter.

Parameters:

  • sourcemap (json)


85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/redsnow/sourcemap.rb', line 85

def initialize(sourcemap)
  super(sourcemap)

  @type = SourceMap.new(sourcemap['type'])
  @use = SourceMap.new(sourcemap['required'])
  @default_value = SourceMap.new(sourcemap['default'])
  @example_value = SourceMap.new(sourcemap['example'])
  @values = []

  sourcemap.key?('values') && sourcemap['values'].each do |value|
    @values << SourceMap.new(value['value'])
  end
end

Instance Attribute Details

#default_valueSourcemap

default value of the parameter or nil

Returns:

  • (Sourcemap)

    the current value of default_value



77
78
79
# File 'lib/redsnow/sourcemap.rb', line 77

def default_value
  @default_value
end

#example_valueSourcemap

example value of the parameter or nil

Returns:

  • (Sourcemap)

    the current value of example_value



77
78
79
# File 'lib/redsnow/sourcemap.rb', line 77

def example_value
  @example_value
end

#typeSourcemap

an arbitrary type of the parameter or nil

Returns:



77
78
79
# File 'lib/redsnow/sourcemap.rb', line 77

def type
  @type
end

#useSourcemap

parameter necessity flag, ‘:required` or `:optional`

Returns:



77
78
79
# File 'lib/redsnow/sourcemap.rb', line 77

def use
  @use
end

#valuesArray<Sourcemap>

an enumeration of possible parameter values

Returns:

  • (Array<Sourcemap>)

    the current value of values



77
78
79
# File 'lib/redsnow/sourcemap.rb', line 77

def values
  @values
end