Module: Pythonism::Pythonize::Numeric

Included in:
Fixnum, String
Defined in:
lib/pythonism/pythonize/numeric.rb

Overview

Provide Numeric methods

Instance Method Summary collapse

Instance Method Details

#__add__(other) ⇒ Object

Returns:



28
29
30
# File 'lib/pythonism/pythonize/numeric.rb', line 28

def __add__(other)
  self + other
end

#__and__(other) ⇒ Object

Returns:



48
49
50
# File 'lib/pythonism/pythonize/numeric.rb', line 48

def __and__(other)
  self & other
end

#__float__Float

Returns:

  • (Float)


13
14
15
# File 'lib/pythonism/pythonize/numeric.rb', line 13

def __float__
  to_f
end

#__hex__String

Returns:



23
24
25
# File 'lib/pythonism/pythonize/numeric.rb', line 23

def __hex__
  format('%x', __int__)
end

#__int__Object



3
4
5
# File 'lib/pythonism/pythonize/numeric.rb', line 3

def __int__
  to_i
end

#__long__Integer

Returns:

  • (Integer)


8
9
10
# File 'lib/pythonism/pythonize/numeric.rb', line 8

def __long__
  to_i
end

#__mod__(other) ⇒ Object

Returns:



43
44
45
# File 'lib/pythonism/pythonize/numeric.rb', line 43

def __mod__(other)
  self % other
end

#__mul__(other) ⇒ Object

Returns:



38
39
40
# File 'lib/pythonism/pythonize/numeric.rb', line 38

def __mul__(other)
  self * other
end

#__oct__String

Returns:



18
19
20
# File 'lib/pythonism/pythonize/numeric.rb', line 18

def __oct__
  format('%o', __int__)
end

#__or__(other) ⇒ Object

Returns:



58
59
60
# File 'lib/pythonism/pythonize/numeric.rb', line 58

def __or__(other)
  self | other
end

#__sub__(other) ⇒ Object

Returns:



33
34
35
# File 'lib/pythonism/pythonize/numeric.rb', line 33

def __sub__(other)
  self - other
end

#__xor__(other) ⇒ Object

Returns:



53
54
55
# File 'lib/pythonism/pythonize/numeric.rb', line 53

def __xor__(other)
  self ^ other
end