Class: RegexpExamples::UnicodeCharRanges

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/regexp-examples/unicode_char_ranges.rb

Overview

Interface to the retrieve the character sets that match a regex named property. E.g. ‘/pAlpha/` These matching values are stored, compressed, in a PStore. They are specific to the ruby minor version.

Constant Summary collapse

STORE_FILENAME =

These values were generated by: scripts/unicode_lister.rb Note: Only the first 128 results are listed, for performance. Also, some groups seem to have no matches (weird!)

"unicode_ranges_#{RbConfig::CONFIG['UNICODE_VERSION']}.pstore".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeUnicodeCharRanges

Returns a new instance of UnicodeCharRanges.



18
19
20
# File 'lib/regexp-examples/unicode_char_ranges.rb', line 18

def initialize
  @range_store = PStore.new(unicode_ranges_file)
end

Instance Attribute Details

#range_storeObject (readonly)

Returns the value of attribute range_store.



16
17
18
# File 'lib/regexp-examples/unicode_char_ranges.rb', line 16

def range_store
  @range_store
end

Instance Method Details

#get(key) ⇒ Object Also known as: []



22
23
24
25
26
# File 'lib/regexp-examples/unicode_char_ranges.rb', line 22

def get(key)
  range_store.transaction(true) do
    ranges_to_unicode(range_store[key])
  end
end