Class: Nio::DigitsDef
- Inherits:
-
Object
- Object
- Nio::DigitsDef
- Includes:
- StateEquivalent
- Defined in:
- lib/nio/repdec.rb
Class Method Summary collapse
Instance Method Summary collapse
- #digit_char(v) ⇒ Object
- #digit_char_safe(v) ⇒ Object
- #digit_value(ch_code) ⇒ Object
-
#initialize(ds = '0123456789', cs = true) ⇒ DigitsDef
constructor
A new instance of DigitsDef.
- #is_digit?(ch_code) ⇒ Boolean
- #radix ⇒ Object
Methods included from StateEquivalent
Constructor Details
#initialize(ds = '0123456789', cs = true) ⇒ DigitsDef
Returns a new instance of DigitsDef.
18 19 20 21 22 23 |
# File 'lib/nio/repdec.rb', line 18 def initialize(ds='0123456789', cs=true) @digits = ds @casesens = cs @dncase = (ds.downcase==ds) @radix = @digits.size end |
Class Method Details
Instance Method Details
#digit_char(v) ⇒ Object
32 33 34 |
# File 'lib/nio/repdec.rb', line 32 def digit_char(v) @digits[v] end |
#digit_char_safe(v) ⇒ Object
35 36 37 |
# File 'lib/nio/repdec.rb', line 35 def digit_char_safe(v) v>=0 && v<@radix ? @digits[v] : nil end |
#digit_value(ch_code) ⇒ Object
28 29 30 31 |
# File 'lib/nio/repdec.rb', line 28 def digit_value(ch_code) ch_code = set_case(ch_code) unless @casesens @digits.index(ch_code.chr) end |
#is_digit?(ch_code) ⇒ Boolean
24 25 26 27 |
# File 'lib/nio/repdec.rb', line 24 def is_digit?(ch_code) ch_code = set_case(ch_code) unless @casesens @digits.include?(ch_code) end |
#radix ⇒ Object
38 39 40 |
# File 'lib/nio/repdec.rb', line 38 def radix @radix end |