libaaron 1.0.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/libaaron.rb +37 -0
- metadata +3 -3
data/lib/libaaron.rb
CHANGED
|
@@ -84,6 +84,31 @@ class Array
|
|
|
84
84
|
end
|
|
85
85
|
alias to_h to_hash
|
|
86
86
|
alias to_hsh to_hash
|
|
87
|
+
def rotate(amount)
|
|
88
|
+
type_error_message = "Unexpected type! Array.rotate requires an integer!"
|
|
89
|
+
raise type_error_message unless amount.is_a? Integer
|
|
90
|
+
out_arr = self.dup
|
|
91
|
+
if amount > 0
|
|
92
|
+
amount.times do
|
|
93
|
+
out_arr.push(out_arr.shift)
|
|
94
|
+
end
|
|
95
|
+
elsif amount < 0
|
|
96
|
+
amount.abs.times do
|
|
97
|
+
out_arr.unshift(out_arr.pop)
|
|
98
|
+
end
|
|
99
|
+
elsif amount == 0
|
|
100
|
+
out_arr
|
|
101
|
+
else
|
|
102
|
+
raise type_error_message
|
|
103
|
+
end
|
|
104
|
+
return out_arr
|
|
105
|
+
end
|
|
106
|
+
def mod(index)
|
|
107
|
+
self[index] = yield self[index]
|
|
108
|
+
end
|
|
109
|
+
def rand
|
|
110
|
+
self[Kernel.rand(self.length)]
|
|
111
|
+
end
|
|
87
112
|
end
|
|
88
113
|
|
|
89
114
|
class Numeric
|
|
@@ -92,6 +117,18 @@ class Numeric
|
|
|
92
117
|
pre,post = number.to_s.split(".")
|
|
93
118
|
pre.gsub(/(\d)(?=(\d{#{after}})+$)/, '\0' + value_separator)+(post ? "#{decimal_separator}#{post == "0" ? "0"*trailing_zeroes : post}" : "")
|
|
94
119
|
end
|
|
120
|
+
def thousand
|
|
121
|
+
self*1_000
|
|
122
|
+
end
|
|
123
|
+
def million
|
|
124
|
+
self*1_000_000
|
|
125
|
+
end
|
|
126
|
+
def billion
|
|
127
|
+
self*1_000_000_000
|
|
128
|
+
end
|
|
129
|
+
def trillion
|
|
130
|
+
self*1_000_000_000_000
|
|
131
|
+
end
|
|
95
132
|
end
|
|
96
133
|
|
|
97
134
|
class Struct
|
metadata
CHANGED
|
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
|
4
4
|
prerelease: false
|
|
5
5
|
segments:
|
|
6
6
|
- 1
|
|
7
|
+
- 1
|
|
7
8
|
- 0
|
|
8
|
-
|
|
9
|
-
version: 1.0.3
|
|
9
|
+
version: 1.1.0
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Aaron Lynch
|
|
@@ -14,7 +14,7 @@ autorequire:
|
|
|
14
14
|
bindir: bin
|
|
15
15
|
cert_chain: []
|
|
16
16
|
|
|
17
|
-
date: 2010-
|
|
17
|
+
date: 2010-05-18 00:00:00 -04:00
|
|
18
18
|
default_executable:
|
|
19
19
|
dependencies: []
|
|
20
20
|
|