Class: RegexpExamples::UnicodeCharRanges

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

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"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename = STORE_FILENAME) ⇒ UnicodeCharRanges

Returns a new instance of UnicodeCharRanges.



13
14
15
# File 'lib/regexp-examples/unicode_char_ranges.rb', line 13

def initialize(filename = STORE_FILENAME)
  @range_store = PStore.new(File.expand_path("../../../db/#{filename}", __FILE__))
end

Instance Attribute Details

#range_storeObject (readonly)

Returns the value of attribute range_store.



11
12
13
# File 'lib/regexp-examples/unicode_char_ranges.rb', line 11

def range_store
  @range_store
end

Instance Method Details

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



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

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