bootstripe 0.2.16 → 0.2.17
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.
@@ -1,7 +1,11 @@
|
|
1
1
|
class Numeric
|
2
2
|
|
3
3
|
def clamp(min, max)
|
4
|
-
|
4
|
+
self < min ? min : (self > max ? max : self)
|
5
|
+
end
|
6
|
+
|
7
|
+
def lerp(target_value, percent)
|
8
|
+
self + (target_value - self) * percent.clamp(0, 1.0)
|
5
9
|
end
|
6
10
|
|
7
11
|
def to_period(detailed = true, abbreviated = true)
|
data/lib/bootstripe/version.rb
CHANGED
@@ -8,6 +8,13 @@ describe Numeric do
|
|
8
8
|
5.clamp(6, 8).should == 6
|
9
9
|
end
|
10
10
|
|
11
|
+
it 'should lerp numbers' do
|
12
|
+
5.lerp(10, 0).should eq 5
|
13
|
+
5.lerp(10, 0.5).should eq 7.5
|
14
|
+
5.lerp(10, 1.0).should eq 10
|
15
|
+
5.lerp(10, 2.0).should eq 10
|
16
|
+
end
|
17
|
+
|
11
18
|
it 'should report formatted time accurately' do
|
12
19
|
0.to_formatted_time.should eq '00:00'
|
13
20
|
(60.75).to_formatted_time.should eq '01:01'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstripe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.17
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|