lib/regextest/front/range.rb in regextest-0.1.5 vs lib/regextest/front/range.rb in regextest-0.1.6
- old
+ new
@@ -12,10 +12,11 @@
@@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}")
+ @options = nil
@begin = parse_letter(letter_begin)
if letter_end
@end = parse_letter(letter_end)
else
@end = @begin
@@ -44,13 +45,30 @@
# enumerate
def enumerate
(@begin..@end).to_a
end
+ # set options
+ def set_options(options)
+ TstLog("Range set_options: #{options[:reg_options].inspect}")
+ @options = options
+ end
+
# transform to json format (using codepoints of Unicode)
def json
@@id += 1
- "{\"type\": \"LEX_RANGE\", \"id\": \"G#{@@id}\", \"begin\": #{@begin}, \"end\": #{@end}}"
+ if @options
+ charset = @options[:reg_options].charset
+ else
+ charset = "d"
+ end
+ "{" +
+ "\"type\": \"LEX_RANGE\", " +
+ "\"id\": \"G#{@@id}\", " +
+ "\"begin\": #{@begin}, " +
+ "\"end\": #{@end}, " +
+ "\"charset\": \"#{charset}\"" +
+ "}"
end
end
end
# Test suite (execute when this file is specified in command line)