Skip to content

Commit e2f7e78

Browse files
committed
enable steep strict for oracle.rb
1 parent 01a3a2c commit e2f7e78

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

Steepfile

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ target :lib do
1010
check "lib/compsci/elo.rb"
1111
check "lib/compsci/fibonacci.rb"
1212
check "lib/compsci/fit.rb"
13+
# ...
14+
check "lib/compsci/oracle.rb"
1315

1416
# library "pathname" # Standard libraries
1517
# library "strong_json" # Gems

lib/compsci/oracle.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ def percentage
6464

6565
def prediction
6666
highest = -1
67-
best = nil
67+
best = ''
6868
@freq[@ring.to_s]&.each { |val, count|
6969
if count > highest
7070
best = val
7171
highest = count
7272
end
7373
}
74-
best
74+
best.empty? ? nil : best
7575
end
7676

7777
def update(char)

sig/oracle.rbs

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
module CompSci
2+
module Oracle
3+
class Ring
4+
@limit: Integer
5+
@cursor: Integer
6+
@storage: Array[untyped]
7+
8+
attr_reader limit: Integer
9+
attr_reader cursor: Integer
10+
attr_reader storage: Array[untyped]
11+
12+
def initialize: (?Integer limit) -> void
13+
def update: (untyped val) -> self
14+
def to_s: () -> String
15+
def full?: () -> bool
16+
end
17+
18+
class Model
19+
@ring: Ring
20+
@freq: Hash[String, Hash[String, Integer]]
21+
@pred: Hash[Symbol, Integer]
22+
23+
attr_reader ring: Ring
24+
attr_reader freq: Hash[String, Hash[String, Integer]]
25+
attr_reader pred: Hash[Symbol, Integer]
26+
27+
def initialize: (?Integer limit) -> void
28+
def to_s: () -> String
29+
def ratio: () -> Rational
30+
def percentage: () -> Float
31+
def prediction: () -> String?
32+
def update: (String char) -> self
33+
def accept: (String str) -> self
34+
end
35+
end
36+
end

0 commit comments

Comments
 (0)