Sha256: 33bf13333e7f7d3518e10be9ef28e880a78c732895eda060e89a9c4a85e79a49
Contents?: true
Size: 1.41 KB
Versions: 4
Compression:
Stored size: 1.41 KB
Contents
# encoding: utf-8 # Copyright (C) 2016 Mikio Ikoma require 'regextest/common' require 'regextest/front/case-folding' # case folding hash # Consective codepoints module Regextest::Front::Range class TRange include Regextest::Common @@id = 0 # a class variable for generating unique name of element # Constructor def initialize(letter_begin, letter_end = nil) TstLog("TRange: #{letter_begin}-#{letter_end}") @begin = parse_letter(letter_begin) if letter_end @end = parse_letter(letter_end) else @end = @begin end @offset = -1 # not used in this class @length = -1 # not used in this class end attr_reader :offset, :length # parse letter def parse_letter(letter) case letter when String letter.unpack("U*")[0] when Integer letter when Regextest::Front::Letter::TLetter eval('"' + letter.value + '"').unpack("U*")[0] else raise "Internal error. invalid letter class #{letter}" end end # enumerate def enumerate (@begin..@end).to_a end # transform to json format (using codepoints of Unicode) def json @@id += 1 "{\"type\": \"LEX_RANGE\", \"id\": \"G#{@@id}\", \"begin\": #{@begin}, \"end\": #{@end}}" end end end # Test suite (execute when this file is specified in command line) if __FILE__ == $0 end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
regextest-0.1.5 | lib/regextest/front/range.rb |
regextest-0.1.4 | lib/regextest/front/range.rb |
regextest-0.1.3 | lib/regextest/front/range.rb |
regextest-0.1.2 | lib/regextest/front/range.rb |