Class: TrueClass

Inherits:
Object show all
Defined in:
lib/source/ruby.rb

Overview

The global value true is the only instance of class TrueClass and represents a logically true value in boolean expressions. The class provides operators allowing true to participate correctly in logical expressions.

Instance Method Summary collapse

Instance Method Details

#&(object) ⇒ Object

call-seq:

true & obj -> !!obj

And – returns false if obj is nil or false, true otherwise.



6765
6766
6767
# File 'lib/source/ruby.rb', line 6765

def &(object)
  `this.valueOf()&&$T(object)`
end

#==(obj) ⇒ Object

:nodoc:



6793
6794
6795
# File 'lib/source/ruby.rb', line 6793

def ==(obj) # :nodoc:
  `obj.valueOf&&obj.valueOf()===this.valueOf()`
end

#===(obj) ⇒ Object

:nodoc:



6797
6798
6799
# File 'lib/source/ruby.rb', line 6797

def ===(obj) # :nodoc:
  `obj.valueOf&&obj.valueOf()===this.valueOf()`
end

#^(object) ⇒ Object

call-seq:

true ^ obj -> !obj

Exclusive Or – returns true if obj is nil or false, false otherwise.



6789
6790
6791
# File 'lib/source/ruby.rb', line 6789

def ^(object)
  `this.valueOf()?!$T(object):$T(object)`
end

#eql?(obj) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


6801
6802
6803
# File 'lib/source/ruby.rb', line 6801

def eql?(obj) # :nodoc:
  `obj.valueOf&&obj.valueOf()===this.valueOf()`
end

#equal?(obj) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


6805
6806
6807
# File 'lib/source/ruby.rb', line 6805

def equal?(obj) # :nodoc:
  `obj.valueOf&&obj.valueOf()===this.valueOf()`
end

#hashObject

:nodoc:



6809
6810
6811
# File 'lib/source/ruby.rb', line 6809

def hash # :nodoc:
  `'b_'+this.valueOf()`
end

#object_idObject

:nodoc:



6813
6814
6815
# File 'lib/source/ruby.rb', line 6813

def object_id # :nodoc:
  `this.valueOf()?2:0`
end

#to_sObject

call-seq:

true.to_s -> "true"

The string representation of true is “true”.



6822
6823
6824
# File 'lib/source/ruby.rb', line 6822

def to_s
  `$q(''+this)`
end

#|(object) ⇒ Object

call-seq:

true | obj -> true

Or – returns true. Because obj is an argument to a method call, it is always evaluated; there is no short-circuit evaluation.

true |  a = "A assigned"    #=> true
true || b = "B assigned"    #=> true
[a, b].inspect              #=> ["A assigned", nil]


6779
6780
6781
# File 'lib/source/ruby.rb', line 6779

def |(object)
  `this.valueOf()||$T(object)`
end