Class: RegexpExamples::UnicodeCharRanges
- Inherits:
-
Object
- Object
- RegexpExamples::UnicodeCharRanges
- 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
-
#range_store ⇒ Object
readonly
Returns the value of attribute range_store.
Instance Method Summary collapse
- #get(key) ⇒ Object (also: #[])
-
#initialize ⇒ UnicodeCharRanges
constructor
A new instance of UnicodeCharRanges.
Constructor Details
#initialize ⇒ UnicodeCharRanges
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_store ⇒ Object (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 |