Class: Vra::RequestParameter

Inherits:
Object
  • Object
show all
Defined in:
lib/vra/request_parameters.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, type, value) ⇒ RequestParameter

Returns a new instance of RequestParameter.



40
41
42
43
44
# File 'lib/vra/request_parameters.rb', line 40

def initialize(key, type, value)
  @key   = key
  @type  = type
  @value = value
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



39
40
41
# File 'lib/vra/request_parameters.rb', line 39

def key
  @key
end

#typeObject

Returns the value of attribute type.



39
40
41
# File 'lib/vra/request_parameters.rb', line 39

def type
  @type
end

#valueObject

Returns the value of attribute value.



39
40
41
# File 'lib/vra/request_parameters.rb', line 39

def value
  @value
end

Instance Method Details

#format_valueObject



56
57
58
59
60
61
62
63
64
65
# File 'lib/vra/request_parameters.rb', line 56

def format_value
  case @type
  when 'integer'
    @value.to_i
  when 'string'
    @value.to_s
  else
    @value.to_s
  end
end

#to_hObject



46
47
48
49
50
51
52
53
54
# File 'lib/vra/request_parameters.rb', line 46

def to_h
  {
    'key' => @key,
    'value' => {
      'type' => @type,
      'value' => format_value
    }
  }
end