Class: FFI::Locale::LocaleConv
- Inherits:
-
Object
- Object
- FFI::Locale::LocaleConv
- Defined in:
- lib/ffi-locale.rb
Overview
Structure returned by #localeconv containing information about numeric and monetary notation.
Instance Attribute Summary collapse
-
#currency_symbol ⇒ String
readonly
Local currency symbol, e.g.
-
#decimal_point ⇒ String
readonly
Decimal point character.
-
#frac_digits ⇒ Integer
readonly
Local fractional digits.
-
#grouping ⇒ Array
readonly
Each element is the number of digits in each group; elements with higher indices are farther left.
-
#int_curr_symbol ⇒ String
readonly
First three chars are a currency symbol from ISO 4217.
-
#int_frac_digits ⇒ Integer
readonly
Int’l fractional digits.
-
#int_n_cs_precedes ⇒ Boolean
readonly
true
if #int_curr_symbol precedes a negative value,false
if succeeds. -
#int_n_sep_by_space ⇒ Boolean
readonly
true
iff a space separates #int_curr_symbol from a negative value. -
#int_n_sign_posn ⇒ Integer
readonly
Negative sign position.
-
#int_p_cs_precedes ⇒ Boolean
readonly
true
if #int_curr_symbol precedes a positive value,false
if succeeds. -
#int_p_sep_by_space ⇒ Boolean
readonly
true
iff a space separates #int_curr_symbol from a positive value. -
#int_p_sign_posn ⇒ Integer
readonly
- 0
-
Parentheses surround the quantity and int_curr_symbol.
-
#mon_decimal_point ⇒ String
readonly
Decimal point character, e.g.
-
#mon_grouping ⇒ Array
readonly
Like #grouping element.
-
#mon_thousands_sep ⇒ String
readonly
Thousands separator.
-
#n_cs_precedes ⇒ Boolean
readonly
true
if #currency_symbol precedes a negative value,false
if succeeds. -
#n_sep_by_space ⇒ Boolean
readonly
true
iff a space separates #currency_symbol from a negative value. -
#n_sign_posn ⇒ Integer
readonly
Negative sign position.
-
#negative_sign ⇒ String
readonly
Sign for negative values.
-
#p_cs_precedes ⇒ Boolean
readonly
true
if #currency_symbol precedes a positive value,false
if succeeds. -
#p_sep_by_space ⇒ Boolean
readonly
true
iff a space separates #currency_symbol from a positive value. -
#p_sign_posn ⇒ Integer
readonly
- 0
-
Parentheses surround the quantity and #currency_symbol.
-
#positive_sign ⇒ String
readonly
Sign for positive values.
-
#thousands_sep ⇒ String
readonly
Thousands separator.
Instance Method Summary collapse
-
#initialize(lcs) ⇒ FFI::Locale::LocaleConv
constructor
Used by FFI::Locale.localeconv.
Constructor Details
#initialize(lcs) ⇒ FFI::Locale::LocaleConv
Used by FFI::Locale.localeconv. Should not be called by application code directly.
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/ffi-locale.rb', line 226 def initialize(lcs) lcs.layout.members.each do |key| value = lcs[key] case key when :grouping, :mon_grouping value = value.each_byte.to_a when :p_cs_precedes, :p_sep_precedes, :n_cs_precedes, :p_sep_by_space, :n_cs_precedes, :n_sep_by_space, :int_p_cs_precedes, :int_p_sep_by_space, :int_n_cs_precedes, :int_n_sep_by_space value = value == 1 ? true : false end case value when String if RUBY_VERSION >= '1.9.0' value = value.force_encoding(Encoding.default_external.to_s) end # For 1.8.x you need to handle this yourself. end instance_variable_set("@#{key}", value) end end |
Instance Attribute Details
#currency_symbol ⇒ String (readonly)
Returns Local currency symbol, e.g. "£"
, "$"
.
141 142 143 |
# File 'lib/ffi-locale.rb', line 141 def currency_symbol @currency_symbol end |
#decimal_point ⇒ String (readonly)
Returns Decimal point character.
120 121 122 |
# File 'lib/ffi-locale.rb', line 120 def decimal_point @decimal_point end |
#frac_digits ⇒ Integer (readonly)
Returns Local fractional digits.
163 164 165 |
# File 'lib/ffi-locale.rb', line 163 def frac_digits @frac_digits end |
#grouping ⇒ Array (readonly)
Each element is the number of digits in each group; elements with higher indices are farther left. An element with value CHAR_MAX means that no further grouping is done. An element with value 0 means that the previous element is used for all groups farther left.
131 132 133 |
# File 'lib/ffi-locale.rb', line 131 def grouping @grouping end |
#int_curr_symbol ⇒ String (readonly)
First three chars are a currency symbol from ISO 4217. Fourth char is the separator. For example, "GBP "
, "USD "
.
138 139 140 |
# File 'lib/ffi-locale.rb', line 138 def int_curr_symbol @int_curr_symbol end |
#int_frac_digits ⇒ Integer (readonly)
Returns Int’l fractional digits.
160 161 162 |
# File 'lib/ffi-locale.rb', line 160 def int_frac_digits @int_frac_digits end |
#int_n_cs_precedes ⇒ Boolean (readonly)
Returns true
if #int_curr_symbol precedes a negative value, false
if succeeds.
200 201 202 |
# File 'lib/ffi-locale.rb', line 200 def int_n_cs_precedes @int_n_cs_precedes end |
#int_n_sep_by_space ⇒ Boolean (readonly)
Returns true
iff a space separates #int_curr_symbol from a negative value.
203 204 205 |
# File 'lib/ffi-locale.rb', line 203 def int_n_sep_by_space @int_n_sep_by_space end |
#int_n_sign_posn ⇒ Integer (readonly)
Returns Negative sign position.
217 218 219 |
# File 'lib/ffi-locale.rb', line 217 def int_n_sign_posn @int_n_sign_posn end |
#int_p_cs_precedes ⇒ Boolean (readonly)
Returns true
if #int_curr_symbol precedes a positive value, false
if succeeds.
194 195 196 |
# File 'lib/ffi-locale.rb', line 194 def int_p_cs_precedes @int_p_cs_precedes end |
#int_p_sep_by_space ⇒ Boolean (readonly)
Returns true
iff a space separates #int_curr_symbol from a positive value.
197 198 199 |
# File 'lib/ffi-locale.rb', line 197 def int_p_sep_by_space @int_p_sep_by_space end |
#int_p_sign_posn ⇒ Integer (readonly)
- 0
-
Parentheses surround the quantity and int_curr_symbol.
- 1
-
The sign string precedes the quantity and int_curr_symbol.
- 2
-
The sign string follows the quantity and int_curr_symbol.
- 3
-
The sign string immediately precedes the int_curr_symbol.
- 4
-
The sign string immediately follows the int_curr_symbol.
213 214 215 |
# File 'lib/ffi-locale.rb', line 213 def int_p_sign_posn @int_p_sign_posn end |
#mon_decimal_point ⇒ String (readonly)
Returns Decimal point character, e.g. "."
, ","
.
144 145 146 |
# File 'lib/ffi-locale.rb', line 144 def mon_decimal_point @mon_decimal_point end |
#mon_grouping ⇒ Array (readonly)
Returns Like #grouping element.
151 152 153 |
# File 'lib/ffi-locale.rb', line 151 def mon_grouping @mon_grouping end |
#mon_thousands_sep ⇒ String (readonly)
Returns Thousands separator.
147 148 149 |
# File 'lib/ffi-locale.rb', line 147 def mon_thousands_sep @mon_thousands_sep end |
#n_cs_precedes ⇒ Boolean (readonly)
Returns true
if #currency_symbol precedes a negative value, false
if succeeds.
172 173 174 |
# File 'lib/ffi-locale.rb', line 172 def n_cs_precedes @n_cs_precedes end |
#n_sep_by_space ⇒ Boolean (readonly)
Returns true
iff a space separates #currency_symbol from a negative value.
175 176 177 |
# File 'lib/ffi-locale.rb', line 175 def n_sep_by_space @n_sep_by_space end |
#n_sign_posn ⇒ Integer (readonly)
Returns Negative sign position.
189 190 191 |
# File 'lib/ffi-locale.rb', line 189 def n_sign_posn @n_sign_posn end |
#negative_sign ⇒ String (readonly)
Returns Sign for negative values.
157 158 159 |
# File 'lib/ffi-locale.rb', line 157 def negative_sign @negative_sign end |
#p_cs_precedes ⇒ Boolean (readonly)
Returns true
if #currency_symbol precedes a positive value, false
if succeeds.
166 167 168 |
# File 'lib/ffi-locale.rb', line 166 def p_cs_precedes @p_cs_precedes end |
#p_sep_by_space ⇒ Boolean (readonly)
Returns true
iff a space separates #currency_symbol from a positive value.
169 170 171 |
# File 'lib/ffi-locale.rb', line 169 def p_sep_by_space @p_sep_by_space end |
#p_sign_posn ⇒ Integer (readonly)
- 0
-
Parentheses surround the quantity and #currency_symbol.
- 1
-
The sign string precedes the quantity and #currency_symbol.
- 2
-
The sign string follows the quantity and #currency_symbol.
- 3
-
The sign string immediately precedes the #currency_symbol.
- 4
-
The sign string immediately follows the #currency_symbol.
185 186 187 |
# File 'lib/ffi-locale.rb', line 185 def p_sign_posn @p_sign_posn end |
#positive_sign ⇒ String (readonly)
Returns Sign for positive values.
154 155 156 |
# File 'lib/ffi-locale.rb', line 154 def positive_sign @positive_sign end |
#thousands_sep ⇒ String (readonly)
Returns Thousands separator.
123 124 125 |
# File 'lib/ffi-locale.rb', line 123 def thousands_sep @thousands_sep end |