castle-log 0.0.4 → 0.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c2ba7b79b2070c5297a6378a7c89303b2e601d7c
4
- data.tar.gz: 6026608e14f7660181a5d3692dd397700a4e3ce2
3
+ metadata.gz: 4797c95bdb305b3595774e95cb3286113d71e2af
4
+ data.tar.gz: d026af6d58fc1eeee14c7b7a47e6fbf89ea7b159
5
5
  SHA512:
6
- metadata.gz: 2b80a763bba60ce8ecb986f10d64f43e9243e33d679e8cfec5b736dc4f27b4c1ac64e2071ed9792d174962761a23e3b5851864e0ddf19960f363079a9594b935
7
- data.tar.gz: 669e0d9875a5d59a0da89d7e32e2a9b13c81a8250448ba7fb1671f3351fe18e90bdce76d44f6587e03e374cec3dbbd6c90069f087f276b9d3aff5a843b110823
6
+ metadata.gz: 05ec679d02eff9db2c667b0e24d57c3dfe912999f014dbdb5282731c371aa0c195cdb1ea53ad4f94c2fa3d883a8a3b52dc9398d0c31ba07ce3a312f00e96a7e9
7
+ data.tar.gz: b8deaf1e2c31d3983278df6382afccbadffdc2bdb642f51496f750cd64b8e8250bfe42998d9716813d6c9b6a1dac2a7cb186eafb0c26da0d284b1ac696090246
@@ -21,6 +21,13 @@ module Castle
21
21
  @duration ||= tick * @data.values[0].length
22
22
  end
23
23
 
24
+ # Gets an array of millisecond times that correspond to data points.
25
+ #
26
+ # @return [Array] millisecond times corresponding to data points
27
+ def milliseconds
28
+ @milliseconds ||= build_milliseconds
29
+ end
30
+
24
31
  def throttle?
25
32
  present? 'Throttle'
26
33
  end
@@ -74,13 +81,22 @@ module Castle
74
81
  present? 'Speed'
75
82
  end
76
83
 
77
- def speed
78
- # FIXME need a pole count or something here
79
- @speed ||= int_fields 'Speed'
84
+ # Gets the speed field values.
85
+ #
86
+ # @param [Float] factor value to multiply each speed by
87
+ # @return [Array] speed field values
88
+ def speed factor = 1.0
89
+ @speed ||= int_fields('Speed').map { |s| s * factor }
80
90
  end
81
91
 
82
92
  private
83
93
 
94
+ def build_milliseconds
95
+ count = @data.values[0].length
96
+ increment = tick * 1000.0
97
+ count.times.map { |i| i * increment }
98
+ end
99
+
84
100
  def present? name
85
101
  !@data[name].empty?
86
102
  end
@@ -1,5 +1,5 @@
1
1
  module Castle
2
2
  module Log
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
data/spec/session_spec.rb CHANGED
@@ -16,6 +16,14 @@ describe Castle::Log::Session do
16
16
 
17
17
  its(:duration) { should be_within(0.1).of(569.2) }
18
18
 
19
+ its(:milliseconds) { should have(2846).values }
20
+
21
+ it 'should have some select millisecond values' do
22
+ subject.milliseconds[0].should eql(0.0)
23
+ subject.milliseconds[1500].should eql(300000.0)
24
+ subject.milliseconds[2602].should eql(520400.0)
25
+ end
26
+
19
27
  its(:throttle?) { should be_true }
20
28
 
21
29
  its(:throttle) { should have(2846).values }
@@ -81,9 +89,9 @@ describe Castle::Log::Session do
81
89
  its(:speed) { should have(2846).values }
82
90
 
83
91
  it 'should have some select speed values' do
84
- subject.speed[0].should eql(0)
85
- subject.speed[1250].should eql(91146)
86
- subject.speed[2150].should eql(84366)
92
+ subject.speed(0.02)[0].should be_within(0.01).of(0.0)
93
+ subject.speed(0.02)[1250].should be_within(0.01).of(1822.92)
94
+ subject.speed(0.02)[2150].should be_within(0.01).of(1687.32)
87
95
  end
88
96
 
89
97
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: castle-log
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Veys
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-14 00:00:00.000000000 Z
11
+ date: 2013-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print