Class: TRuby::InferredType

Inherits:
Object
  • Object
show all
Defined in:
lib/t_ruby/type_inferencer.rb

Overview

Represents an inferred type with confidence score

Constant Summary collapse

HIGH =

Confidence levels

1.0
MEDIUM =
0.7
LOW =
0.4

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, confidence: HIGH, source: :unknown, location: nil) ⇒ InferredType

Returns a new instance of InferredType.



13
14
15
16
17
18
# File 'lib/t_ruby/type_inferencer.rb', line 13

def initialize(type:, confidence: HIGH, source: :unknown, location: nil)
  @type = type
  @confidence = confidence
  @source = source
  @location = location
end

Instance Attribute Details

#confidenceObject (readonly)

Returns the value of attribute confidence.



6
7
8
# File 'lib/t_ruby/type_inferencer.rb', line 6

def confidence
  @confidence
end

#locationObject (readonly)

Returns the value of attribute location.



6
7
8
# File 'lib/t_ruby/type_inferencer.rb', line 6

def location
  @location
end

#sourceObject (readonly)

Returns the value of attribute source.



6
7
8
# File 'lib/t_ruby/type_inferencer.rb', line 6

def source
  @source
end

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/t_ruby/type_inferencer.rb', line 6

def type
  @type
end

Instance Method Details

#high_confidence?Boolean

Returns:



24
25
26
# File 'lib/t_ruby/type_inferencer.rb', line 24

def high_confidence?
  @confidence >= HIGH
end

#low_confidence?Boolean

Returns:



32
33
34
# File 'lib/t_ruby/type_inferencer.rb', line 32

def low_confidence?
  @confidence < MEDIUM
end

#medium_confidence?Boolean

Returns:



28
29
30
# File 'lib/t_ruby/type_inferencer.rb', line 28

def medium_confidence?
  @confidence >= MEDIUM && @confidence < HIGH
end

#to_sObject



20
21
22
# File 'lib/t_ruby/type_inferencer.rb', line 20

def to_s
  @type
end