ruby / csv

CSV Reading and Writing
https://ruby.github.io/csv/
BSD 2-Clause "Simplified" License
178 stars 113 forks source link

Readable prefix/suffix removal in Parser#strip_value #251

Closed Maumagnaguagno closed 2 years ago

Maumagnaguagno commented 2 years ago

The use of String#delete_prefix!/delete_suffix! makes this method more readable. It also makes possible to strip strings with more than one character.

Note that I am using the methods ending with ! to modify value, this matches the already used strip!. I also modified the early return to show that value is always returned, and with this PR all value modifications happen in-place. This could be used to further simplify the method itself (no need to return a value) and the single usage I have found in Parser#parse_no_quote: line = strip_value(line) to strip_value(line).

I have not done this modification yet to leave it open for discussion.

kou commented 2 years ago

Thanks!