red-data-tools / unicode_plot.rb

Plot your data by Unicode characters
MIT License
249 stars 12 forks source link

How about raising an ArgumentError when the border is unknown? #41

Closed kojix2 closed 3 years ago

kojix2 commented 3 years ago
require 'unicode_plot'

x = 0.step(3*Math::PI, by: 3*Math::PI / 30)
y_sin = x.map {|xi| Math.sin(xi) }
UnicodePlot.lineplot(x, y_sin, border: :stripe).render # Unknown border type

Expected behavior

raise ArgumentError, "unknown border type: #{border_type}"

Current behavior

undefined method `[]' for nil:NilClass (NoMethodError)
kojix2 commented 3 years ago

I thought about sending a pull request, but I didn't know where to put the raise.

mrkn commented 3 years ago

@kojix2 Do you want only an appropriate exception? Don't you need to access the list of border types like #42?

kojix2 commented 3 years ago

Just checking whether a border is available can help you understand the error message. Of course, having a list of borders is more useful.