erlang_c_calculator 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +16 -0
- data/erlang_c_calculator.gemspec +2 -0
- data/lib/erlang_c/version.rb +1 -1
- data/lib/erlang_c_calculator.rb +5 -8
- metadata +24 -13
- data/lib/math.rb +0 -15
- data/spec/math_spec.rb +0 -34
data/Gemfile.lock
ADDED
data/erlang_c_calculator.gemspec
CHANGED
@@ -21,4 +21,6 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
22
22
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
23
23
|
s.require_paths = ["lib"]
|
24
|
+
|
25
|
+
s.add_development_dependency 'rspec', '~> 1.3'
|
24
26
|
end
|
data/lib/erlang_c/version.rb
CHANGED
data/lib/erlang_c_calculator.rb
CHANGED
@@ -1,19 +1,16 @@
|
|
1
|
-
require 'math'
|
2
|
-
|
3
1
|
module ErlangC
|
4
2
|
class Calculator
|
5
|
-
include Math
|
6
3
|
|
7
4
|
attr_accessor :arrival_rate, :serv_time, :wait_time
|
8
|
-
|
5
|
+
|
9
6
|
def initialize(arrival_rate, serv_time, wait_time = 30)
|
10
7
|
@arrival_rate, @serv_time, @wait_time = arrival_rate, serv_time, wait_time
|
11
8
|
end
|
12
|
-
|
9
|
+
|
13
10
|
def traffic_intensity
|
14
11
|
(arrival_rate * serv_time).to_f
|
15
12
|
end
|
16
|
-
|
13
|
+
|
17
14
|
def erlang_c_probability(m)
|
18
15
|
u = traffic_intensity
|
19
16
|
|
@@ -30,10 +27,10 @@ module ErlangC
|
|
30
27
|
def agents_needed
|
31
28
|
agents = (traffic_intensity + 1).to_i
|
32
29
|
while average_wait(agents) >= wait_time
|
33
|
-
|
30
|
+
agents += 1
|
34
31
|
end
|
35
32
|
agents
|
36
33
|
end
|
37
|
-
|
34
|
+
|
38
35
|
end
|
39
36
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: erlang_c_calculator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Chandu Tennety
|
@@ -15,10 +15,23 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
date: 2012-05-31 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 9
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 3
|
32
|
+
version: "1.3"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
22
35
|
description: |-
|
23
36
|
Given the average call arrival rate per second, the average
|
24
37
|
service time and acceptable wait time, calculate the load,
|
@@ -36,15 +49,13 @@ files:
|
|
36
49
|
- .gitignore
|
37
50
|
- .rvmrc
|
38
51
|
- Gemfile
|
52
|
+
- Gemfile.lock
|
39
53
|
- MIT-License.md
|
40
54
|
- README.md
|
41
55
|
- Rakefile
|
42
56
|
- erlang_c_calculator.gemspec
|
43
57
|
- lib/erlang_c/version.rb
|
44
58
|
- lib/erlang_c_calculator.rb
|
45
|
-
- lib/math.rb
|
46
|
-
- spec/math_spec.rb
|
47
|
-
has_rdoc: true
|
48
59
|
homepage: http://rubygems.org/gems/erlang_c_calculator
|
49
60
|
licenses: []
|
50
61
|
|
@@ -74,9 +85,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
85
|
requirements: []
|
75
86
|
|
76
87
|
rubyforge_project: erlang_c_calculator
|
77
|
-
rubygems_version: 1.
|
88
|
+
rubygems_version: 1.8.21
|
78
89
|
signing_key:
|
79
90
|
specification_version: 3
|
80
91
|
summary: Calculate the various terms associated with the Erlang C formula.
|
81
|
-
test_files:
|
82
|
-
|
92
|
+
test_files: []
|
93
|
+
|
data/lib/math.rb
DELETED
data/spec/math_spec.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'spec'
|
2
|
-
require 'lib/erlang_c_calculator'
|
3
|
-
require 'lib/math'
|
4
|
-
|
5
|
-
module ErlangC
|
6
|
-
describe Math do
|
7
|
-
before do
|
8
|
-
class TestClass
|
9
|
-
include Math
|
10
|
-
end
|
11
|
-
|
12
|
-
@test = TestClass.new
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "#factorial" do
|
16
|
-
it "for 5 should be 120" do
|
17
|
-
@test.factorial(5).should == 120
|
18
|
-
end
|
19
|
-
|
20
|
-
it "for 1 should be 1" do
|
21
|
-
@test.factorial(1).should == 1
|
22
|
-
end
|
23
|
-
|
24
|
-
it "for 0 should be 1" do
|
25
|
-
@test.factorial(0).should == 1
|
26
|
-
end
|
27
|
-
|
28
|
-
it "for 2 should be 2" do
|
29
|
-
@test.factorial(2).should == 2
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|