Class: SecID::Suggestion

Inherits:
Data
  • Object
show all
Defined in:
lib/sec_id/suggestion.rb,
lib/sec_id/suggestion.rb

Overview

Reopened to add the domain enumerations and serialization helpers per the repo convention (see Base#as_json).

Constant Summary collapse

EDIT_KINDS =

The edit kinds edit can take, in rank order (see SecID::Suggestable::RANK).

%i[substitution transposition checksum].freeze
CONFIDENCE_LEVELS =

The non-nil confidence tiers confidence can take; :checksum candidates carry nil.

%i[high medium].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#confidenceSymbol? (readonly)

Returns :high (homoglyph), :medium (transposition), or nil (:checksum).

Returns:

  • (Symbol, nil)

    :high (homoglyph), :medium (transposition), or nil (:checksum)



38
# File 'lib/sec_id/suggestion.rb', line 38

Suggestion = Data.define(:type, :identifier, :edit, :position, :from, :to, :confidence)

#editSymbol (readonly)

Returns :substitution, :transposition, or :checksum.

Returns:

  • (Symbol)

    :substitution, :transposition, or :checksum



38
# File 'lib/sec_id/suggestion.rb', line 38

Suggestion = Data.define(:type, :identifier, :edit, :position, :from, :to, :confidence)

#fromString (readonly)

Returns the original character(s).

Returns:

  • (String)

    the original character(s)



38
# File 'lib/sec_id/suggestion.rb', line 38

Suggestion = Data.define(:type, :identifier, :edit, :position, :from, :to, :confidence)

#identifierSecID::Base (readonly)

Returns the valid, parsed corrected identifier.

Returns:

  • (SecID::Base)

    the valid, parsed corrected identifier



38
# File 'lib/sec_id/suggestion.rb', line 38

Suggestion = Data.define(:type, :identifier, :edit, :position, :from, :to, :confidence)

#positionInteger? (readonly)

Returns the edit position (nil for :checksum).

Returns:

  • (Integer, nil)

    the edit position (nil for :checksum)



38
# File 'lib/sec_id/suggestion.rb', line 38

Suggestion = Data.define(:type, :identifier, :edit, :position, :from, :to, :confidence)

#toString (readonly)

Returns the replacement character(s).

Returns:

  • (String)

    the replacement character(s)



38
# File 'lib/sec_id/suggestion.rb', line 38

Suggestion = Data.define(:type, :identifier, :edit, :position, :from, :to, :confidence)

#typeSymbol (readonly)

Returns the identifier type key (e.g. :isin).

Returns:

  • (Symbol)

    the identifier type key (e.g. :isin)



38
# File 'lib/sec_id/suggestion.rb', line 38

Suggestion = Data.define(:type, :identifier, :edit, :position, :from, :to, :confidence)

Instance Method Details

#as_jsonHash

Returns the symbol-keyed field hash (JSON-compatible).

Returns:

  • (Hash)

    the symbol-keyed field hash (JSON-compatible)



50
51
52
# File 'lib/sec_id/suggestion.rb', line 50

def as_json(*)
  to_h
end

#to_sString

Returns the corrected identifier string.

Returns:

  • (String)

    the corrected identifier string



55
56
57
# File 'lib/sec_id/suggestion.rb', line 55

def to_s
  identifier.to_s
end