Module: Boolean

Includes:
Comparable
Included in:
FalseClass, TrueClass
Defined in:
lib/is-boolean.rb

Instance Method Summary collapse

Instance Method Details

#<=>(other) ⇒ Integer

false < true

Returns:

  • (Integer)


19
20
21
22
23
24
25
# File 'lib/is-boolean.rb', line 19

def <=>(other)
  if other.is_a?(Boolean)
    self.to_i <=> other.to_i
  else
    nil
  end
end

#to_iInteger

false0 true1

Returns:

  • (Integer)


9
10
11
12
13
14
15
# File 'lib/is-boolean.rb', line 9

def to_i
  if self
    1
  else
    0
  end
end