Class: Optionable::Any

Inherits:
Object
  • Object
show all
Defined in:
lib/optionable/any.rb

Overview

Represents an option that can be of any value of a certain type.

Since:

  • 0.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ Any

Initialize the new any value object.

Examples:

Initialize the any value object.

Optionable::Any.new(Integer)

Parameters:

  • type (Class)

    The class type.

Since:

  • 0.0.0



33
34
35
# File 'lib/optionable/any.rb', line 33

def initialize(type)
  @type = type
end

Instance Attribute Details

#typeObject

Since:

  • 0.0.0



11
12
13
# File 'lib/optionable/any.rb', line 11

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object

Check equality of the value for this type.

Examples:

Check if the value equals this type.

any == 10

Parameters:

  • other (Object)

    The object to check against.

Since:

  • 0.0.0



21
22
23
# File 'lib/optionable/any.rb', line 21

def ==(other)
  other.is_a?(type)
end

#inspectString

Return the pretty inspected type.

Examples:

Get the any as an inspection.

any.inspect

Returns:

  • (String)

    any + the class type.

Since:

  • 0.0.0



45
46
47
# File 'lib/optionable/any.rb', line 45

def inspect
  "any #{type}"
end