Class: Mindee::Parsing::Standard::LocaleField
- Inherits:
-
Object
- Object
- Mindee::Parsing::Standard::LocaleField
- Defined in:
- lib/mindee/parsing/standard/locale_field.rb
Overview
Represents locale information
Instance Attribute Summary collapse
-
#confidence ⇒ Float
readonly
The confidence score, value will be between 0.0 and 1.0.
-
#country ⇒ String?
readonly
Country code in ISO 3166-1 alpha-2 format.
-
#currency ⇒ String
readonly
Currency code in ISO 4217 format.
-
#language ⇒ String
readonly
Language code in ISO 639-1 format.
-
#value ⇒ String
readonly
Language code, with country code when available.
Instance Method Summary collapse
-
#initialize(prediction, _page_id = nil) ⇒ LocaleField
constructor
A new instance of LocaleField.
- #to_s ⇒ String
Constructor Details
#initialize(prediction, _page_id = nil) ⇒ LocaleField
Returns a new instance of LocaleField.
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/mindee/parsing/standard/locale_field.rb', line 25 def initialize(prediction, _page_id = nil) value_key = if !prediction.include?('value') || prediction['value'].nil? 'language' else 'value' end @confidence = prediction['confidence'] @value = prediction[value_key] @language = prediction['language'] @country = prediction['country'] @currency = prediction['currency'] end |
Instance Attribute Details
#confidence ⇒ Float (readonly)
The confidence score, value will be between 0.0 and 1.0
10 11 12 |
# File 'lib/mindee/parsing/standard/locale_field.rb', line 10 def confidence @confidence end |
#country ⇒ String? (readonly)
Country code in ISO 3166-1 alpha-2 format.
16 17 18 |
# File 'lib/mindee/parsing/standard/locale_field.rb', line 16 def country @country end |
#currency ⇒ String (readonly)
Currency code in ISO 4217 format.
19 20 21 |
# File 'lib/mindee/parsing/standard/locale_field.rb', line 19 def currency @currency end |
#language ⇒ String (readonly)
Language code in ISO 639-1 format.
13 14 15 |
# File 'lib/mindee/parsing/standard/locale_field.rb', line 13 def language @language end |
#value ⇒ String (readonly)
Language code, with country code when available.
22 23 24 |
# File 'lib/mindee/parsing/standard/locale_field.rb', line 22 def value @value end |
Instance Method Details
#to_s ⇒ String
39 40 41 42 43 44 45 46 |
# File 'lib/mindee/parsing/standard/locale_field.rb', line 39 def to_s out_str = String.new out_str << "#{@value}; " unless @value.nil? out_str << "#{@language}; " if @language out_str << "#{@country}; " if @country out_str << "#{@currency}; " if @currency out_str.strip end |