Class: Module

Inherits:
Object show all
Defined in:
lib/module.rb

Instance Method Summary collapse

Instance Method Details

#<(object) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/module.rb', line 84

def <( object )
  
  is_less_than = less_than( object )
  
  if is_less_than.nil?
    # a class is < another class if it has the other class as one of its ancestors
    if self != object and 
       ::IdentifiesAs.object_instance_identifies_as?( self, object )
      is_less_than = true
    end
  end
      
  return is_less_than
  
end

#<=(object) ⇒ Object



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/module.rb', line 133

def <=( object )
  
  is_less_than_or_equal_to = less_than_or_equal_to( object )
  
  if is_less_than_or_equal_to.nil?
    # a class is < another class if it has the other class as one of its ancestors
    if self == object or 
       ::IdentifiesAs.object_instance_identifies_as?( self, object )
      is_less_than_or_equal_to = true
    end
  end
      
  return is_less_than_or_equal_to
  
end

#<=>(object) ⇒ Object



182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/module.rb', line 182

def <=>( object )
  
  less_than_equal_to_greater_than = nil
  
  if self == object
    less_than_equal_to_greater_than = 0
  elsif self < object
    less_than_equal_to_greater_than = -1
  elsif self > object
    less_than_equal_to_greater_than = 1
  end
  
  return less_than_equal_to_greater_than
  
end

#===(object) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/module.rb', line 62

def ===( object )
  
  is_equal = false
  
  if ::IdentifiesAs.respond_to?( :object_identifies_as? ) and 
     ::IdentifiesAs.case_compare( object )                and
     ::IdentifiesAs.object_identifies_as?( object, self )
    is_equal = true
  else
    is_equal = case_compare( object )
  end

  return is_equal
  
end

#>(object) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/module.rb', line 106

def >( object )

  is_greater_than = greater_than( object )
  
  if is_greater_than.nil?
    # a class is > another class if the other class has it as one of its ancestors
    if self != object and 
       ::IdentifiesAs.object_instance_identifies_as?( object, self )
      is_greater_than = true
    else
      is_less_than = self < object
      unless is_less_than.nil?
        is_greater_than = ! is_less_than
      end
    end
  end
      
  return is_greater_than
  
end

#>=(object) ⇒ Object



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/module.rb', line 155

def >=( object )

  is_greater_than_or_equal_to = greater_than_or_equal_to( object )
  
  if is_greater_than_or_equal_to.nil?
    # a class is < another class if it has the other class as one of its ancestors
    if self == object or 
       ::IdentifiesAs.object_instance_identifies_as?( object, self )
      is_greater_than_or_equal_to = true
    else
      is_less_than_or_equal_to = self <= object
      unless is_less_than_or_equal_to.nil?
        is_greater_than_or_equal_to = ! is_less_than_or_equal_to
      end
    end
  end
      
  return is_greater_than_or_equal_to
  
end

#case_compareObject

#



60
# File 'lib/module.rb', line 60

alias_method :case_compare, :===

#compareObject

<=> #



180
# File 'lib/module.rb', line 180

alias_method :compare, :<=>

#greater_thanObject

> #



104
# File 'lib/module.rb', line 104

alias_method :greater_than, :>

#greater_than_or_equal_toObject

>= #



153
# File 'lib/module.rb', line 153

alias_method :greater_than_or_equal_to, :>=

#instance_identitiesArray<Object>

Identities that instances of receiver identify as, beyond those which it actually is.

Returns:

  • (Array<Object>)

    Identities instances of receiver identifies as.



37
38
39
40
41
# File 'lib/module.rb', line 37

def instance_identities
  
  return ::IdentifiesAs.object_instance_identities( self )    
  
end

#instances_identify_as!(*objects) ⇒ Object

Cause instances of receiver to identify as specified objects.

Parameters:

  • objects (Array<Object>)

    Other objects self should identify as.

Returns:



11
12
13
14
15
# File 'lib/module.rb', line 11

def instances_identify_as!( *objects )
  
  return ::IdentifiesAs.object_instances_identify_as!( self, *objects )
  
end

#instances_identify_as?(object) ⇒ true, false

Query whether instances of receiver identify as specified object.

Parameters:

  • object (Object)

    Object against which identity is being tested.

Returns:

  • (true, false)

    Whether instances of receiver identify as object.



24
25
26
27
28
# File 'lib/module.rb', line 24

def instances_identify_as?( object )
  
  return ::IdentifiesAs.object_instances_identify_as?( self, object )    
  
end

#less_thanObject

< #



82
# File 'lib/module.rb', line 82

alias_method :less_than, :<

#less_than_or_equal_toObject

<= #



131
# File 'lib/module.rb', line 131

alias_method :less_than_or_equal_to, :<=

#stop_instances_identifying_as!(*objects) ⇒ Object

Cause instances of receiver to no longer identify as specified objects.

Parameters:

  • objects (Array<Object>)

    Other objects instance of receiver should no longer identify as.

Returns:



50
51
52
53
54
# File 'lib/module.rb', line 50

def stop_instances_identifying_as!( *objects )
  
  return ::IdentifiesAs.stop_object_instances_identifying_as!( self, *objects )    
  
end