Class: Ast::Merge::MatchRefinerBase::MatchResult

Inherits:
Struct
  • Object
show all
Defined in:
lib/ast/merge/match_refiner_base.rb

Overview

Result of a match refinement operation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dest_nodeObject (readonly)

Returns The node from the destination.

Returns:

  • (Object)

    The node from the destination



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/ast/merge/match_refiner_base.rb', line 140

MatchResult = Struct.new(:template_node, :dest_node, :score, :metadata, keyword_init: true) do
  # Check if this is a high-confidence match.
  #
  # @param threshold [Float] Minimum score for high confidence (default: 0.8)
  # @return [Boolean]
  def high_confidence?(threshold: 0.8)
    score >= threshold
  end

  # Compare match results by score for sorting.
  #
  # @param other [MatchResult]
  # @return [Integer] -1, 0, or 1
  def <=>(other)
    score <=> other.score
  end
end

#metadataHash (readonly)

Returns Optional metadata about the match.

Returns:

  • (Hash)

    Optional metadata about the match



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/ast/merge/match_refiner_base.rb', line 140

MatchResult = Struct.new(:template_node, :dest_node, :score, :metadata, keyword_init: true) do
  # Check if this is a high-confidence match.
  #
  # @param threshold [Float] Minimum score for high confidence (default: 0.8)
  # @return [Boolean]
  def high_confidence?(threshold: 0.8)
    score >= threshold
  end

  # Compare match results by score for sorting.
  #
  # @param other [MatchResult]
  # @return [Integer] -1, 0, or 1
  def <=>(other)
    score <=> other.score
  end
end

#scoreFloat (readonly)

Returns Match score between 0.0 and 1.0.

Returns:

  • (Float)

    Match score between 0.0 and 1.0



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/ast/merge/match_refiner_base.rb', line 140

MatchResult = Struct.new(:template_node, :dest_node, :score, :metadata, keyword_init: true) do
  # Check if this is a high-confidence match.
  #
  # @param threshold [Float] Minimum score for high confidence (default: 0.8)
  # @return [Boolean]
  def high_confidence?(threshold: 0.8)
    score >= threshold
  end

  # Compare match results by score for sorting.
  #
  # @param other [MatchResult]
  # @return [Integer] -1, 0, or 1
  def <=>(other)
    score <=> other.score
  end
end

#template_nodeObject (readonly)

Returns The node from the template.

Returns:

  • (Object)

    The node from the template



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/ast/merge/match_refiner_base.rb', line 140

MatchResult = Struct.new(:template_node, :dest_node, :score, :metadata, keyword_init: true) do
  # Check if this is a high-confidence match.
  #
  # @param threshold [Float] Minimum score for high confidence (default: 0.8)
  # @return [Boolean]
  def high_confidence?(threshold: 0.8)
    score >= threshold
  end

  # Compare match results by score for sorting.
  #
  # @param other [MatchResult]
  # @return [Integer] -1, 0, or 1
  def <=>(other)
    score <=> other.score
  end
end

Instance Method Details

#<=>(other) ⇒ Integer

Compare match results by score for sorting.

Parameters:

Returns:

  • (Integer)

    -1, 0, or 1



153
154
155
# File 'lib/ast/merge/match_refiner_base.rb', line 153

def <=>(other)
  score <=> other.score
end

#high_confidence?(threshold: 0.8) ⇒ Boolean

Check if this is a high-confidence match.

Parameters:

  • threshold (Float) (defaults to: 0.8)

    Minimum score for high confidence (default: 0.8)

Returns:

  • (Boolean)


145
146
147
# File 'lib/ast/merge/match_refiner_base.rb', line 145

def high_confidence?(threshold: 0.8)
  score >= threshold
end