Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/unicode/display_width.rb
Instance Method Summary collapse
- #display_length(*args) ⇒ Object
- #display_size(*args) ⇒ Object
- #display_width(ambiguous = 1) ⇒ Object
Instance Method Details
#display_length(*args) ⇒ Object
50 51 52 53 |
# File 'lib/unicode/display_width.rb', line 50 def display_length(*args) warn "Deprecation warning: Please use `String#display_width` instead of `String#display_length`" display_width(*args) end |
#display_size(*args) ⇒ Object
45 46 47 48 |
# File 'lib/unicode/display_width.rb', line 45 def display_size(*args) warn "Deprecation warning: Please use `String#display_width` instead of `String#display_size`" display_width(*args) end |
#display_width(ambiguous = 1) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/unicode/display_width.rb', line 30 def display_width(ambiguous = 1) unpack('U*').inject(0){ |total_width, char| total_width + case Unicode::DisplayWidth.codepoint(char).to_s when 'F', 'W' 2 when 'N', 'Na', 'H' 1 when 'A' ambiguous else 1 end } end |