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!) (Don’t care about ruby micro version number)

"unicode_ranges_#{RUBY_VERSION[0..2]}.pstore".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeUnicodeCharRanges

Returns a new instance of UnicodeCharRanges.



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

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

Instance Attribute Details

#range_storeObject (readonly)

Returns the value of attribute range_store.



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

def range_store
  @range_store
end

Instance Method Details

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



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

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