Class: TwitterCldr::Utils::ScriptDetectionResult
- Inherits:
-
Object
- Object
- TwitterCldr::Utils::ScriptDetectionResult
- Defined in:
- lib/twitter_cldr/utils/script_detector.rb
Instance Attribute Summary collapse
-
#scores ⇒ Object
readonly
Returns the value of attribute scores.
Instance Method Summary collapse
- #best_guess ⇒ Object
-
#initialize(scores) ⇒ ScriptDetectionResult
constructor
A new instance of ScriptDetectionResult.
- #score_for(script_name) ⇒ Object
- #scripts ⇒ Object
Constructor Details
#initialize(scores) ⇒ ScriptDetectionResult
Returns a new instance of ScriptDetectionResult.
12 13 14 |
# File 'lib/twitter_cldr/utils/script_detector.rb', line 12 def initialize(scores) @scores = scores end |
Instance Attribute Details
#scores ⇒ Object (readonly)
Returns the value of attribute scores.
10 11 12 |
# File 'lib/twitter_cldr/utils/script_detector.rb', line 10 def scores @scores end |
Instance Method Details
#best_guess ⇒ Object
16 17 18 19 |
# File 'lib/twitter_cldr/utils/script_detector.rb', line 16 def best_guess max_score = scores.max_by { |(_, score)| score } max_score.first if max_score end |
#score_for(script_name) ⇒ Object
21 22 23 |
# File 'lib/twitter_cldr/utils/script_detector.rb', line 21 def score_for(script_name) scores[script_name] end |
#scripts ⇒ Object
25 26 27 |
# File 'lib/twitter_cldr/utils/script_detector.rb', line 25 def scripts scores.keys end |