Module: Unicode::NumericValue
- Defined in:
- lib/unicode/numeric_value.rb,
lib/unicode/numeric_value/index.rb,
lib/unicode/numeric_value/constants.rb
Constant Summary collapse
- INDEX =
Marshal.load(Gem::Util.gunzip(File.binread(INDEX_FILENAME)))
- VERSION =
"1.3.1".freeze
- UNICODE_VERSION =
"10.0.0".freeze
- DATA_DIRECTORY =
File.(File.dirname(__FILE__) + '/../../../data/').freeze
- INDEX_FILENAME =
(DATA_DIRECTORY + '/numeric_value.marshal.gz').freeze
Class Method Summary collapse
- .chars ⇒ Object
- .numeric_value(char) ⇒ Object (also: of)
Class Method Details
.chars ⇒ Object
13 14 15 16 |
# File 'lib/unicode/numeric_value.rb', line 13 def self.chars require_relative "numeric_value/index" unless defined? ::Unicode::NumericValue::INDEX INDEX.keys.sort.map{ |codepoint| [codepoint].pack("U") } end |
.numeric_value(char) ⇒ Object Also known as: of
5 6 7 8 9 10 |
# File 'lib/unicode/numeric_value.rb', line 5 def self.numeric_value(char) codepoint = char.unpack("U")[0] or raise(ArgumentError, "Unicode::NumericValue.numeric_value must be given a valid char") require_relative "numeric_value/index" unless defined? ::Unicode::NumericValue::INDEX INDEX[codepoint] end |