Class: Goby::C

Inherits:
Object
  • Object
show all
Defined in:
lib/goby/util.rb

Overview

Stores a pair of values as a couple.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(first, second) ⇒ C

Returns a new instance of C.

Parameters:

  • first (Object)

    the first object in the pair.

  • second (Object)

    the second object in the pair.



21
22
23
24
# File 'lib/goby/util.rb', line 21

def initialize(first, second)
  @first = first
  @second = second
end

Instance Attribute Details

#firstObject

Returns the value of attribute first.



31
32
33
# File 'lib/goby/util.rb', line 31

def first
  @first
end

#secondObject

Returns the value of attribute second.



31
32
33
# File 'lib/goby/util.rb', line 31

def second
  @second
end

Class Method Details

.[](first, second) ⇒ Object

Syntactic sugar to create a couple using C[a, b]

Parameters:

  • first (Object)

    the first object in the pair.

  • second (Object)

    the second object in the pair.



15
16
17
# File 'lib/goby/util.rb', line 15

def self.[](first, second)
  C.new(first, second)
end

Instance Method Details

#==(rhs) ⇒ Object

Parameters:

  • rhs (C)

    the couple on the right.



27
28
29
# File 'lib/goby/util.rb', line 27

def ==(rhs)
  return ((@first == rhs.first) && (@second == rhs.second))
end