class Parameters::ClassParam

Attributes

value[R]

Default value of the class parameter

Public Class Methods

new(name,type=nil,description=nil,value=nil) click to toggle source

Creates a new ClassParam object.

@param [Symbol, String] name

The name of the class parameter.

@param [Class, Array] type

The enforced type of the class parameter.

@param [String, nil] description

The description of the class parameter.

@param [Object, nil] value

The default value of the class parameter.
Calls superclass method
# File lib/parameters/class_param.rb, line 24
def initialize(name,type=nil,description=nil,value=nil)
  super(name,type,description)

  @value = value
end

Public Instance Methods

inspect() click to toggle source

Inspects the class parameter.

@return [String]

Inspection of the class params value.
# File lib/parameters/class_param.rb, line 87
def inspect
  "#<#{self.class}: #{@value.inspect}>"
end
to_instance(object) click to toggle source

Creates an instance parameter from the class param.

@param [Object] object

The object the instance parameter should be connected to.

@return [InstanceParam]

The new instance parameter.

@since 0.3.0

@api semipublic

# File lib/parameters/class_param.rb, line 58
def to_instance(object)
  InstanceParam.new(
    object,
    @name,
    @type,
    @description,
    @value
  )
end
to_s() click to toggle source

@return [String]

The representation of the class param.
# File lib/parameters/class_param.rb, line 72
def to_s
  text = @name.to_s

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

  return text
end
value=(new_value) click to toggle source

Sets the value of the class param.

@param [Object] new_value

The new value of the class param.

@return [Object]

The new value of the class param.

@since 0.2.0

# File lib/parameters/class_param.rb, line 41
def value=(new_value)
  @value = coerce(new_value)
end