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.



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

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

#==(obj) ⇒ Object

:nodoc:



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

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

#===(obj) ⇒ Object

:nodoc:



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

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.



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

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

#eql?(obj) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


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

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

#equal?(obj) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


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

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

#hashObject

:nodoc:



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

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

#object_idObject

:nodoc:



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

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

#to_sObject

call-seq:

true.to_s -> "true"

The string representation of true is “true”.



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

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]


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

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