andys_convenience_methods 0.0.3 → 0.0.4
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.
- checksums.yaml +4 -4
- data/lib/andy_convenience.rb +21 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a98e1ab75eddf1f350339dad013e18f835606fa6
|
4
|
+
data.tar.gz: 8073016868a5c0f62e6f2f9158559123167623e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbc30d775cb8344fe4eafb389ceb7db13f3e9016f2baa4d813ea78ca188f35370a49de513a9763fe76f84873569d536527789313021fad9b33be4f9a5673e43a
|
7
|
+
data.tar.gz: 9b546ed5fc51e0e62fbe40c8b31cc9a7ba2e708bd291e7f5c4b3508bae7e91719ecfab28efd8ee9ec6ad0dc5d510ca9dfa299e924e7769a26bbd42dac75c41aa
|
data/lib/andy_convenience.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
|
1
3
|
class String
|
2
4
|
def to_binary
|
3
5
|
ascii = []
|
@@ -5,6 +7,13 @@ class String
|
|
5
7
|
ascii.map{ |n| n.to_binary }.join(' ')
|
6
8
|
end
|
7
9
|
|
10
|
+
def webitize(tag, options = nil)
|
11
|
+
if options
|
12
|
+
options = ' ' + (options.map {|k, v| "#{k}='#{v}'"}.join(' '))
|
13
|
+
end
|
14
|
+
"<#{tag}#{options}>#{self}</#{tag}>"
|
15
|
+
end
|
16
|
+
|
8
17
|
def crunch(str)
|
9
18
|
str.chars.chunk{|s| s}.map(&:first).join
|
10
19
|
end
|
@@ -37,6 +46,11 @@ class String
|
|
37
46
|
def idx(coll)
|
38
47
|
coll[self.to_i - 1]
|
39
48
|
end
|
49
|
+
|
50
|
+
alias_method :strc, :stringcrement
|
51
|
+
alias_method :stinc, :increment
|
52
|
+
alias_method :idxmt, :indexment
|
53
|
+
alias_method :to_web, :webitize
|
40
54
|
end
|
41
55
|
|
42
56
|
class Integer
|
@@ -50,6 +64,10 @@ class Integer
|
|
50
64
|
self.increment(interval, operator, seq).to_s
|
51
65
|
end
|
52
66
|
|
67
|
+
def to_tkn
|
68
|
+
SecureRandom.urlsafe_base64(self)
|
69
|
+
end
|
70
|
+
|
53
71
|
def to_binary
|
54
72
|
final_string = ''
|
55
73
|
bins = binlib.select { |n| n <= self }.reverse
|
@@ -68,6 +86,9 @@ class Integer
|
|
68
86
|
final_string
|
69
87
|
end
|
70
88
|
|
89
|
+
alias_method :strc, :stringcrement
|
90
|
+
alias_method :inc, :increment
|
91
|
+
|
71
92
|
private
|
72
93
|
|
73
94
|
def binlib
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: andys_convenience_methods
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Rosenberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A few convenience methods
|
14
14
|
email: andynaterosenberg@gmail.com
|