Module: Pythonism::Functions::Builtin
- Defined in:
- lib/pythonism/functions/builtin.rb
Overview
Define Pythonic Built-in Functions
Instance Method Summary collapse
- #bool(*obj) ⇒ Boolean, Method
- #float(*obj) ⇒ Float, Class
- #hex(*obj) ⇒ String, Class
- #int(*obj) ⇒ Fixnum, ...
- #list(*obj) ⇒ Array, Class
- #long(*obj) ⇒ Fixnum, ...
- #oct(*obj) ⇒ String, Class
- #str(*obj) ⇒ String, Class
- #type(*obj) ⇒ Class
Instance Method Details
#bool(*obj) ⇒ Boolean, Method
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/pythonism/functions/builtin.rb', line 6 def bool(*obj) case obj.size when 0 method(:bool) when 1 obj[0].__nonzero__ else raise ArgumentError end end |
#float(*obj) ⇒ Float, Class
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/pythonism/functions/builtin.rb', line 71 def float(*obj) case obj.size when 0 Float when 1 obj[0].__float__ else raise ArgumentError end end |
#hex(*obj) ⇒ String, Class
95 96 97 98 99 100 101 102 103 104 |
# File 'lib/pythonism/functions/builtin.rb', line 95 def hex(*obj) case obj.size when 0 method(:hex) when 1 obj[0].__hex__ else raise ArgumentError end end |
#int(*obj) ⇒ Fixnum, ...
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/pythonism/functions/builtin.rb', line 45 def int(*obj) case obj.size when 0 Fixnum when 1 obj[0].__int__ else raise ArgumentError end end |
#list(*obj) ⇒ Array, Class
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/pythonism/functions/builtin.rb', line 32 def list(*obj) case obj.size when 0 Array when 1 obj[0].to_a else raise ArgumentError end end |
#long(*obj) ⇒ Fixnum, ...
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/pythonism/functions/builtin.rb', line 58 def long(*obj) case obj.size when 0 Bignum when 1 obj[0].__long__ else raise ArgumentError end end |
#oct(*obj) ⇒ String, Class
108 109 110 111 112 113 114 115 116 117 |
# File 'lib/pythonism/functions/builtin.rb', line 108 def oct(*obj) case obj.size when 0 method(:oct) when 1 obj[0].__oct__ else raise ArgumentError end end |