Class: Parameters::InstanceParam

Inherits:
Param show all
Defined in:
lib/parameters/instance_param.rb

Instance Attribute Summary

Instance Method Summary

Constructor Details

- (InstanceParam) initialize(object, name, description = nil)

Creates a new InstanceParam object.

Parameters:

  • (Object) object — The object containing the instance variable for the instance parameter.
  • (Symbol, String) name — The name of the instance parameter.
  • (String, nil) description (defaults to: nil) — The description of the instance parameter.


20
21
22
23
24
# File 'lib/parameters/instance_param.rb', line 20

def initialize(object,name,description=nil)
  super(name,description)

  @object = object
end

Instance Attribute Details

- (Object) object (readonly)

Owning object



5
6
7
# File 'lib/parameters/instance_param.rb', line 5

def object
  @object
end

Instance Method Details

- (String) inspect

Inspection of the instance params value.

Returns:

  • (String) — Inspection of the instance params value.


64
65
66
# File 'lib/parameters/instance_param.rb', line 64

def inspect
  value.inspect
end

- (String) to_s

Representation of the instance param.

Returns:

  • (String) — Representation of the instance param.


51
52
53
54
55
56
57
58
# File 'lib/parameters/instance_param.rb', line 51

def to_s
  text = @name.to_s

  text << " [#{value.inspect}]" if value
  text << "\t#{@description}" if @description

  return text
end

- (Object) value

The value of the instance param.

Returns:

  • The value of the instance param.


30
31
32
# File 'lib/parameters/instance_param.rb', line 30

def value
  @object.instance_variable_get("@#{@name}".to_sym)
end

- (Object) value=(value)

Sets the value of the instance param.

Parameters:

  • (Object) value — The new value of the instance param.

Returns:

  • (Object) — The new value of the instance param.


43
44
45
# File 'lib/parameters/instance_param.rb', line 43

def value=(value)
  @object.instance_variable_set("@#{@name}".to_sym,value)
end