Class: Integer
Overview
The Integer class
Constant Summary collapse
- N_BYTES =
Some math constants
[42].pack('i').size
- N_BITS =
N_BYTES * 8
- MAX =
(2**(N_BITS - 2)) - 1
- MIN =
- 1
Instance Method Summary collapse
- #+(other) ⇒ Object
- #<(other) ⇒ Object
- #<=(other) ⇒ Object
- #==(other) ⇒ Object
- #>(other) ⇒ Object
- #>=(other) ⇒ Object
- #equals_operator ⇒ Object
- #greaterthan_operator ⇒ Object
- #greaterthanorequal_operator ⇒ Object
- #lessthan_operator ⇒ Object
- #lessthanorequal_operator ⇒ Object
- #number? ⇒ Boolean
- #plus_operator ⇒ Object
Instance Method Details
#+(other) ⇒ Object
302 303 304 305 306 307 308 309 |
# File 'lib/runtime/mixins.rb', line 302 def +(other) case other when String then format(JoinedTemplate, str: self.to_s, other: other.to_s) when NilClass, FalseClass then self + 0 when TrueClass then self + 1 else plus_operator(other) end end |
#<(other) ⇒ Object
266 267 268 269 270 271 272 |
# File 'lib/runtime/mixins.rb', line 266 def <(other) case other when NilClass, FalseClass then self < 0 when TrueClass then self < 1 else lessthan_operator(other) end end |
#<=(other) ⇒ Object
275 276 277 278 279 280 281 |
# File 'lib/runtime/mixins.rb', line 275 def <=(other) case other when NilClass, FalseClass then self <= 0 when TrueClass then self <= 1 else lessthanorequal_operator(other) end end |
#==(other) ⇒ Object
257 258 259 260 261 262 263 |
# File 'lib/runtime/mixins.rb', line 257 def ==(other) case other when NilClass, FalseClass then self == 0 when TrueClass then self == 1 else equals_operator(other) end end |
#>(other) ⇒ Object
284 285 286 287 288 289 290 |
# File 'lib/runtime/mixins.rb', line 284 def >(other) case other when NilClass, FalseClass then self > 0 when TrueClass then self > 1 else greaterthan_operator(other) end end |
#>=(other) ⇒ Object
293 294 295 296 297 298 299 |
# File 'lib/runtime/mixins.rb', line 293 def >=(other) case other when NilClass, FalseClass then self >= 0 when TrueClass then self >= 1 else greaterthanorequal_operator(other) end end |
#equals_operator ⇒ Object
256 |
# File 'lib/runtime/mixins.rb', line 256 alias equals_operator == |
#greaterthan_operator ⇒ Object
283 |
# File 'lib/runtime/mixins.rb', line 283 alias greaterthan_operator > |
#greaterthanorequal_operator ⇒ Object
292 |
# File 'lib/runtime/mixins.rb', line 292 alias greaterthanorequal_operator >= |
#lessthan_operator ⇒ Object
265 |
# File 'lib/runtime/mixins.rb', line 265 alias lessthan_operator < |
#lessthanorequal_operator ⇒ Object
274 |
# File 'lib/runtime/mixins.rb', line 274 alias lessthanorequal_operator <= |
#number? ⇒ Boolean
311 312 313 |
# File 'lib/runtime/mixins.rb', line 311 def number? true end |
#plus_operator ⇒ Object
301 |
# File 'lib/runtime/mixins.rb', line 301 alias plus_operator + |