Module: Trith::Core::Comparison

Defined in:
lib/trith/core/comparison.rb

Overview

Comparison operators.

See Also:

Instance Method Summary (collapse)

Instance Method Details

- (Integer) cmp(a, b) Also known as: <=>

Parameters:

  • (Object) a
  • (Object) b

Returns:

  • (Integer)


13
14
15
# File 'lib/trith/core/comparison.rb', line 13

def cmp(a, b)
  a <=> b
end

- (Boolean) eq(a, b)

Parameters:

  • (Object) a
  • (Object) b

Returns:



22
23
24
# File 'lib/trith/core/comparison.rb', line 22

def eq(a, b)
  a == b
end

- (Boolean) ge(a, b) Also known as: >=

Parameters:

  • (Object) a
  • (Object) b

Returns:



67
68
69
# File 'lib/trith/core/comparison.rb', line 67

def ge(a, b)
  a >= b
end

- (Boolean) gt(a, b) Also known as: >

Parameters:

  • (Object) a
  • (Object) b

Returns:



58
59
60
# File 'lib/trith/core/comparison.rb', line 58

def gt(a, b)
  a > b
end

- (Boolean) le(a, b) Also known as: <=

Parameters:

  • (Object) a
  • (Object) b

Returns:



49
50
51
# File 'lib/trith/core/comparison.rb', line 49

def le(a, b)
  a <= b
end

- (Boolean) lt(a, b) Also known as: <

Parameters:

  • (Object) a
  • (Object) b

Returns:



40
41
42
# File 'lib/trith/core/comparison.rb', line 40

def lt(a, b)
  a < b
end

- (Object) max(a, b)

Parameters:

  • (Object) a
  • (Object) b

Returns:

  • (Object)


84
85
86
# File 'lib/trith/core/comparison.rb', line 84

def max(a, b)
  [a, b].max
end

- (Object) min(a, b)

Parameters:

  • (Object) a
  • (Object) b

Returns:

  • (Object)


76
77
78
# File 'lib/trith/core/comparison.rb', line 76

def min(a, b)
  [a, b].min
end

- (Boolean) ne(a, b)

Parameters:

  • (Object) a
  • (Object) b

Returns:



31
32
33
# File 'lib/trith/core/comparison.rb', line 31

def ne(a, b)
  a != b
end