Class: Numerals::Options
- Inherits:
-
Object
- Object
- Numerals::Options
- Includes:
- ModalSupport::BracketConstructor, ModalSupport::StateEquivalent
- Defined in:
- lib/numerals/formatting/options.rb
Overview
Repeating decimal configuration options
Instance Attribute Summary collapse
-
#auto_rep ⇒ Object
Returns the value of attribute auto_rep.
-
#begin_rep ⇒ Object
Returns the value of attribute begin_rep.
-
#dec_sep ⇒ Object
Returns the value of attribute dec_sep.
-
#digits ⇒ Object
Returns the value of attribute digits.
-
#end_rep ⇒ Object
Returns the value of attribute end_rep.
-
#grp ⇒ Object
Returns the value of attribute grp.
-
#grp_sep ⇒ Object
Returns the value of attribute grp_sep.
-
#inf_txt ⇒ Object
Returns the value of attribute inf_txt.
-
#maximum_number_of_digits ⇒ Object
Returns the value of attribute maximum_number_of_digits.
-
#minus_sign ⇒ Object
Returns the value of attribute minus_sign.
-
#nan_txt ⇒ Object
Returns the value of attribute nan_txt.
-
#plus_sign ⇒ Object
Returns the value of attribute plus_sign.
Instance Method Summary collapse
- #digits_defined? ⇒ Boolean
-
#initialize(options = {}) ⇒ Options
constructor
A new instance of Options.
- #set_delim(begin_d, end_d = '') ⇒ Object
- #set_digits(*args) ⇒ Object
- #set_grouping(sep, g = []) ⇒ Object
- #set_sep(d) ⇒ Object
- #set_signs(plus, minus) ⇒ Object
- #set_special(nan_txt, inf_txt) ⇒ Object
- #set_suffix(a) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Options
Returns a new instance of Options.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/numerals/formatting/options.rb', line 9 def initialize(={}) = { # default options delim: ['<', '>'], suffix: '...', sep: '.', grouping: [',', []], # [...,[3]] for thousands separators special: ['NaN', 'Infinity'], digits: nil, signs: ['+', '-'], maximum_number_of_digits: Numeral.maximum_number_of_digits }.merge() set_delim *Array([:delim]) set_suffix [:suffix] set_sep [:sep] set_grouping *Array([:grouping]) set_special *Array([:special]) set_digits *Array([:digits]) set_signs *Array([:signs]) @maximum_number_of_digits = [:maximum_number_of_digits] end |
Instance Attribute Details
#auto_rep ⇒ Object
Returns the value of attribute auto_rep.
32 33 34 |
# File 'lib/numerals/formatting/options.rb', line 32 def auto_rep @auto_rep end |
#begin_rep ⇒ Object
Returns the value of attribute begin_rep.
32 33 34 |
# File 'lib/numerals/formatting/options.rb', line 32 def begin_rep @begin_rep end |
#dec_sep ⇒ Object
Returns the value of attribute dec_sep.
32 33 34 |
# File 'lib/numerals/formatting/options.rb', line 32 def dec_sep @dec_sep end |
#digits ⇒ Object
Returns the value of attribute digits.
74 75 76 |
# File 'lib/numerals/formatting/options.rb', line 74 def digits @digits end |
#end_rep ⇒ Object
Returns the value of attribute end_rep.
32 33 34 |
# File 'lib/numerals/formatting/options.rb', line 32 def end_rep @end_rep end |
#grp ⇒ Object
Returns the value of attribute grp.
32 33 34 |
# File 'lib/numerals/formatting/options.rb', line 32 def grp @grp end |
#grp_sep ⇒ Object
Returns the value of attribute grp_sep.
32 33 34 |
# File 'lib/numerals/formatting/options.rb', line 32 def grp_sep @grp_sep end |
#inf_txt ⇒ Object
Returns the value of attribute inf_txt.
33 34 35 |
# File 'lib/numerals/formatting/options.rb', line 33 def inf_txt @inf_txt end |
#maximum_number_of_digits ⇒ Object
Returns the value of attribute maximum_number_of_digits.
32 33 34 |
# File 'lib/numerals/formatting/options.rb', line 32 def maximum_number_of_digits @maximum_number_of_digits end |
#minus_sign ⇒ Object
Returns the value of attribute minus_sign.
33 34 35 |
# File 'lib/numerals/formatting/options.rb', line 33 def minus_sign @minus_sign end |
#nan_txt ⇒ Object
Returns the value of attribute nan_txt.
33 34 35 |
# File 'lib/numerals/formatting/options.rb', line 33 def nan_txt @nan_txt end |
#plus_sign ⇒ Object
Returns the value of attribute plus_sign.
33 34 35 |
# File 'lib/numerals/formatting/options.rb', line 33 def plus_sign @plus_sign end |
Instance Method Details
#digits_defined? ⇒ Boolean
76 77 78 |
# File 'lib/numerals/formatting/options.rb', line 76 def digits_defined? @digits_defined end |
#set_delim(begin_d, end_d = '') ⇒ Object
35 36 37 38 39 |
# File 'lib/numerals/formatting/options.rb', line 35 def set_delim(begin_d, end_d='') @begin_rep = begin_d @end_rep = end_d return self end |
#set_digits(*args) ⇒ Object
63 64 65 66 67 |
# File 'lib/numerals/formatting/options.rb', line 63 def set_digits(*args) @digits_defined = !args.empty? @digits = DigitsDefinition[*args] self end |
#set_grouping(sep, g = []) ⇒ Object
51 52 53 54 55 |
# File 'lib/numerals/formatting/options.rb', line 51 def set_grouping(sep, g=[]) @grp_sep = sep @grp = g return self end |
#set_sep(d) ⇒ Object
46 47 48 49 |
# File 'lib/numerals/formatting/options.rb', line 46 def set_sep(d) @dec_sep = d return self end |
#set_signs(plus, minus) ⇒ Object
69 70 71 72 |
# File 'lib/numerals/formatting/options.rb', line 69 def set_signs(plus, minus) @plus_sign = plus @minus_sign = minus end |
#set_special(nan_txt, inf_txt) ⇒ Object
57 58 59 60 61 |
# File 'lib/numerals/formatting/options.rb', line 57 def set_special(nan_txt, inf_txt) @nan_txt = nan_txt @inf_txt = inf_txt return self end |
#set_suffix(a) ⇒ Object
41 42 43 44 |
# File 'lib/numerals/formatting/options.rb', line 41 def set_suffix(a) @auto_rep = a return self end |