flash_extensions 3.1.0 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 229c104e7e71c8cfad52dfdaa45cad36e08cb883
4
- data.tar.gz: 29eff6d52d6c7e47aa890ddd049f1e438d22bf7f
3
+ metadata.gz: c4a7aafeb611b94c20ec6deecf5e604714e55482
4
+ data.tar.gz: b5d57365ddd985af4abebde381662d624b90fb59
5
5
  SHA512:
6
- metadata.gz: 30ee2e9968417e5e148f518bc4356eebf0a1b6b14336eb627c1b0b0d04c34a89ef16eb89fd0f253f0dc2c35fbdeacf916f2b69d6f2b427465f5c6be86d5691e0
7
- data.tar.gz: 9d0ea5d0c42ff3ae27f24603b2a73003631ef6e5c99696dcea6262ad45531ee793b36b3cb5c3c9caf93172f3e40ea8b71a2ca9c891b71d020d4216b86ae41cb3
6
+ metadata.gz: d40db1ddc4db820c4364e1ac382e1c2786d199d0ea4921f007a27cf364ff59bae43fc613277562bbba6d74478d649e8c374ba7a0f6c5b6123d78c7b89ad54d9e
7
+ data.tar.gz: 9fd19ad1ee7ba42da595e539fc214b57b98cad4d9a5650f8a57d3267d16e57f842007dbbe28c9e821d4daa45ac7131e3e50978f2a89db004bbf38ef13119464c
@@ -1,7 +1,7 @@
1
1
  class Array
2
2
 
3
3
  def remove_blanks
4
- reject { |e| e.blank? }
4
+ reject { |value| value.blank? }
5
5
  end
6
6
 
7
7
  def remove_first
@@ -2,7 +2,7 @@ module Enumerable
2
2
 
3
3
  unless method_defined?(:sum)
4
4
  def sum(identity=0)
5
- inject { |s, e| s + e } || identity
5
+ inject(:+) || identity
6
6
  end
7
7
  end
8
8
 
@@ -16,10 +16,10 @@ module Enumerable
16
16
  def drop_last_while
17
17
  return to_enum(:drop_last_while) unless block_given?
18
18
 
19
- result = []
19
+ result = []
20
20
  dropping = true
21
- reverse_each do |obj|
22
- result.unshift(obj) unless dropping &&= yield(obj)
21
+ reverse_each do |value|
22
+ result.unshift(value) unless dropping &&= yield(value)
23
23
  end
24
24
  result
25
25
  end
@@ -29,15 +29,11 @@ module Enumerable
29
29
 
30
30
  if block_given?
31
31
  each do |*o|
32
- if yield(*o)
33
- found_count += 1
34
- end
32
+ found_count += 1 if yield(*o)
35
33
  end
36
34
  else
37
35
  each do |o|
38
- if o
39
- found_count += 1
40
- end
36
+ found_count += 1 if o
41
37
  end
42
38
  end
43
39
 
@@ -58,7 +54,7 @@ module Enumerable
58
54
 
59
55
  def mean(identity=0)
60
56
  collection_size = size
61
- collection_size > 0 ? inject(&:+) / collection_size.to_f : identity
57
+ collection_size > 0 ? inject(:+) / collection_size.to_f : identity
62
58
  end
63
59
 
64
60
  def median(identity=0)
@@ -79,14 +75,14 @@ module Enumerable
79
75
  def mode(identity=0)
80
76
  if size > 0
81
77
  frequency_distribution = inject(Hash.new(0)) { |h, v| h[v] += 1; h }
82
- top_2 = frequency_distribution.sort { |a, b| b[1] <=> a[1] }.take(2)
78
+ frequency_top_2 = frequency_distribution.sort { |a, b| b[1] <=> a[1] }.take(2)
83
79
 
84
- if top_2.length == 1
85
- top_2.first.first
86
- elsif top_2.first.last == top_2.last.last
80
+ if frequency_top_2.length == 1
81
+ frequency_top_2.first.first
82
+ elsif frequency_top_2.first.last == frequency_top_2.last.last
87
83
  nil
88
84
  else
89
- top_2.first.first
85
+ frequency_top_2.first.first
90
86
  end
91
87
  else
92
88
  identity
@@ -103,15 +99,11 @@ module Enumerable
103
99
 
104
100
  if block_given?
105
101
  each do |*o|
106
- if yield(*o)
107
- found_count += 1
108
- end
102
+ found_count += 1 if yield(*o)
109
103
  end
110
104
  else
111
105
  each do |o|
112
- if o
113
- found_count += 1
114
- end
106
+ found_count += 1 if o
115
107
  end
116
108
  end
117
109
 
@@ -129,7 +121,7 @@ module Enumerable
129
121
  return to_enum(:take_last_while) unless block_given?
130
122
 
131
123
  result = []
132
- reverse_each { |e| yield(e) ? result.unshift(e) : break }
124
+ reverse_each { |e| yield(e) ? result.unshift(e) : break }
133
125
  result
134
126
  end
135
127
 
@@ -17,7 +17,7 @@ class Numeric
17
17
  def to_byte(from=:b, to=:kb)
18
18
  scalers = { b: 1, kb: 1024 ** 1, mb: 1024 ** 2, gb: 1024 ** 3, tb: 1024 ** 4, pb: 1024 ** 5, eb: 1024 ** 6 }
19
19
 
20
- self.to_f * scalers[from] / scalers[to]
20
+ to_f * scalers[from] / scalers[to]
21
21
  end
22
22
 
23
23
  def to_length(from=:mm, to=:in)
@@ -35,15 +35,15 @@ class Numeric
35
35
  self
36
36
  when :mm, :cm, :m, :km
37
37
  if [:in, :ft, :yd, :mi, :nm].include?(from)
38
- self.to_f * imperical_scalers[from] * imperical_scalers[to]
38
+ to_f * imperical_scalers[from] * imperical_scalers[to]
39
39
  else
40
- self.to_f * metric_scalers[from] / metric_scalers[to]
40
+ to_f * metric_scalers[from] / metric_scalers[to]
41
41
  end
42
42
  when :in, :ft, :yd, :mi, :nm
43
43
  if [:mm, :cm, :m, :km].include?(from)
44
- self.to_f * metric_scalers[from] * metric_scalers[to]
44
+ to_f * metric_scalers[from] * metric_scalers[to]
45
45
  else
46
- self.to_f * imperical_scalers[from] / imperical_scalers[to]
46
+ to_f * imperical_scalers[from] / imperical_scalers[to]
47
47
  end
48
48
  end
49
49
  end
@@ -53,14 +53,14 @@ class Numeric
53
53
  when from
54
54
  self
55
55
  when :c, :celsius
56
- (self.to_f - 32) * 5 / 9
56
+ (to_f - 32) * 5 / 9
57
57
  when :f, :fahrenheit
58
- (self.to_f * 9 / 5) + 32
58
+ (to_f * 9 / 5) + 32
59
59
  when :k, :kelvin
60
60
  if [:c, :celsius].include?(from)
61
- self.to_f + 273.15
61
+ to_f + 273.15
62
62
  else
63
- ((self.to_f - 32) * 5 / 9) + 273.15
63
+ ((to_f - 32) * 5 / 9) + 273.15
64
64
  end
65
65
  end
66
66
  end
@@ -68,7 +68,7 @@ class Numeric
68
68
  def to_time_unit(from=:sec, to=:min)
69
69
  scalers = { sec: 1, min: 60 ** 1, hr: 60 ** 2, day: (60 ** 2) * 24, yr: (60 ** 2) * 24 * 365 }
70
70
 
71
- self.to_f * scalers[from] / scalers[to]
71
+ to_f * scalers[from] / scalers[to]
72
72
  end
73
73
 
74
74
  def to_weight(from=:g, to=:oz)
@@ -86,15 +86,15 @@ class Numeric
86
86
  self
87
87
  when :mg, :cg, :g, :kg, :mt
88
88
  if [:oz, :lb, :tn].include?(from)
89
- self.to_f * imperical_scalers[from] * imperical_scalers[to]
89
+ to_f * imperical_scalers[from] * imperical_scalers[to]
90
90
  else
91
- self.to_f * metric_scalers[from] / metric_scalers[to]
91
+ to_f * metric_scalers[from] / metric_scalers[to]
92
92
  end
93
93
  when :oz, :lb, :tn
94
94
  if [:mg, :cg, :g, :kg, :mt].include?(from)
95
- self.to_f * metric_scalers[from] * metric_scalers[to]
95
+ to_f * metric_scalers[from] * metric_scalers[to]
96
96
  else
97
- self.to_f * imperical_scalers[from] / imperical_scalers[to]
97
+ to_f * imperical_scalers[from] / imperical_scalers[to]
98
98
  end
99
99
  end
100
100
  end
@@ -23,7 +23,7 @@ class Object
23
23
  end
24
24
 
25
25
  def palindrome?
26
- to_s.reverse == to_s
26
+ to_s == to_s.reverse
27
27
  end
28
28
 
29
29
  end
@@ -1,3 +1,3 @@
1
1
  module FlashExtensions
2
- VERSION = "3.1.0"
2
+ VERSION = "3.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flash_extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-14 00:00:00.000000000 Z
11
+ date: 2014-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  version: '0'
120
120
  requirements: []
121
121
  rubyforge_project:
122
- rubygems_version: 2.4.2
122
+ rubygems_version: 2.4.4
123
123
  signing_key:
124
124
  specification_version: 4
125
125
  summary: Commonly used object helpers