lib/dolos/string_io_wrapper.rb in dolos-0.2.0 vs lib/dolos/string_io_wrapper.rb in dolos-0.2.1

- old
+ new

@@ -20,16 +20,11 @@ io.seek(offset) end def matches?(utf8_str) read = io.read(utf8_str.bytesize) - - if read.nil? - false - else - read.force_encoding('UTF-8') == utf8_str - end + !read.nil? && read.force_encoding('UTF-8') == utf8_str end def advance(bytesize) @offset += bytesize io.seek(offset) @@ -59,11 +54,11 @@ current_position = io.pos remaining_data = io.read io.seek(current_position) - if (match_data = remaining_data.match(/\A#{pattern}/)) - matched_string = match_data[0] + if remaining_data =~ /\A#{pattern}/ + matched_string = $& io.seek(current_position + matched_string.bytesize) return matched_string end nil