lib/regextest/back/main.rb in regextest-0.1.3 vs lib/regextest/back/main.rb in regextest-0.1.4
- old
+ new
@@ -264,12 +264,11 @@
# range
def generate_candidates_range(param)
target = param[:json]
letter = []
codepoints = (target["begin"]..target["end"]).to_a
- letter = codepoints.map{| codepoint | [codepoint].pack("U*")} # to be faster
- result = Regextest::Back::Element.new({cmd: :CMD_SELECT, data: letter})
+ result = Regextest::Back::Element.new({cmd: :CMD_SELECT, data: codepoints})
end
# back_refer
def generate_candidates_back_refer(param)
target = param[:json]
@@ -303,18 +302,20 @@
# char
def generate_candidates_char(param)
target = param[:json]
case target["value"]
when String
- result = Regextest::Back::Element.new({cmd: :CMD_SELECT, data: [target["value"]]})
+ codepoint = target["value"].unpack("U*")[0]
+ result = Regextest::Back::Element.new({cmd: :CMD_SELECT, data: [codepoint]})
else
result = generate_candidates({json: target["value"]})
end
result
end
# narrow down candidates considering anchors
def narrow_down_candidates(candidate_array)
+ # pp candidate_array
results = Regextest::Back::Result.new
candidate_array.each do | elem |
command = elem.command
case command
when :CMD_SELECT