Class: Integer

Inherits:
Object show all
Defined in:
lib/story_teller/mixins.rb

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

Instance Method Details

#+(other) ⇒ Object



303
304
305
306
307
308
309
310
# File 'lib/story_teller/mixins.rb', line 303

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



267
268
269
270
271
272
273
# File 'lib/story_teller/mixins.rb', line 267

def <(other)
  case other
  when NilClass, FalseClass then self < 0
  when TrueClass then self < 1
  else lessthan_operator(other)
  end
end

#<=(other) ⇒ Object



276
277
278
279
280
281
282
# File 'lib/story_teller/mixins.rb', line 276

def <=(other)
  case other
  when NilClass, FalseClass then self <= 0
  when TrueClass then self <= 1
  else lessthanorequal_operator(other)
  end
end

#==(other) ⇒ Object



258
259
260
261
262
263
264
# File 'lib/story_teller/mixins.rb', line 258

def ==(other)
  case other
  when NilClass, FalseClass then self == 0
  when TrueClass then self == 1
  else equals_operator(other)
  end
end

#>(other) ⇒ Object



285
286
287
288
289
290
291
# File 'lib/story_teller/mixins.rb', line 285

def >(other)
  case other
  when NilClass, FalseClass then self > 0
  when TrueClass then self > 1
  else greaterthan_operator(other)
  end
end

#>=(other) ⇒ Object



294
295
296
297
298
299
300
# File 'lib/story_teller/mixins.rb', line 294

def >=(other)
  case other
  when NilClass, FalseClass then self >= 0
  when TrueClass then self >= 1
  else greaterthanorequal_operator(other)
  end
end

#equals_operatorObject



257
# File 'lib/story_teller/mixins.rb', line 257

alias equals_operator ==

#greaterthan_operatorObject



284
# File 'lib/story_teller/mixins.rb', line 284

alias greaterthan_operator >

#greaterthanorequal_operatorObject



293
# File 'lib/story_teller/mixins.rb', line 293

alias greaterthanorequal_operator >=

#lessthan_operatorObject



266
# File 'lib/story_teller/mixins.rb', line 266

alias lessthan_operator <

#lessthanorequal_operatorObject



275
# File 'lib/story_teller/mixins.rb', line 275

alias lessthanorequal_operator <=

#number?Boolean

Returns:

  • (Boolean)


312
313
314
# File 'lib/story_teller/mixins.rb', line 312

def number?
  true
end

#plus_operatorObject



302
# File 'lib/story_teller/mixins.rb', line 302

alias plus_operator +