Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request/Question: Unit.is_valid?("unitname") #156

Open
johnhutch opened this issue Jun 7, 2017 · 3 comments
Open

Feature Request/Question: Unit.is_valid?("unitname") #156

johnhutch opened this issue Jun 7, 2017 · 3 comments

Comments

@johnhutch
Copy link

Hey there! I'm wondering if there's currently a way to do something like the above, or what you recommend if one wanted to determine whether or not one is using a valid unit, or if you think it's better to rescue the exception. Thanks!

@olbrich
Copy link
Owner

olbrich commented Jun 7, 2017

right now you will have to rescue the exception thrown when parsing. It's a good suggestion that I will explore incorporating in the next version.

@johnhutch
Copy link
Author

Thanks much!

@dipil-saud
Copy link

dipil-saud commented Dec 19, 2017

@johnhutch I think you can use Unit.defined?("unitname") for this purpose.
Edit: Unit.defined? does not recognize prefixes so it won't work for those cases e.g. Unit.defined?('cm') is false but Unit.new('cm') will work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants