用于在 Ruby 中转换物理单位(千克、磅)的库?
我知道 Rails 有一些用于日期和时间管理的好帮手。是否有一个已经在运行的项目包含或包含用于标准单位及其转换的干净 DSL?任何带有帮助程序在两个系统的长度和重量基本单位之间进行转换的项目都可以工作。谢谢你!
I know Rails has some nice helpers for date and time management. Is there an already-working project consisting of, or incorporating a clean DSL for standard units and their conversions? Any project with helpers for the conversion between the two systems' basic units of length and weight would work. Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
哇,这些东西比我想象的要多得多。这是我认为的完整列表,按字母顺序排列,示例用法从其文档中删除。我还注意到我是否无法让它们在本地运行。
炼金术士
测量
这个似乎已经过时了,最后一次提交是 5 年前,而且它似乎无法在我的 1.9.3 上运行。
物理单位
数量
请注意,自述文件中指出它尚未准备好用于生产。
SY
请参阅Boris Stitnickey 的回答。
ruby-measurement
ruby-units
Ruby 单位
Unitwise
货车/单元
像另一位海报一样,我在实现此功能时遇到了困难。不过,您可以查看 Jörg W Mittag 的回答以了解用法。
作为 Unitwise 的作者,很明显它是我最喜欢的。不过,我鼓励您至少检查一下。
Wow, there are quite a few more of these than I expected. Here is what I believe to be a complete list, in alphabetical order, with example usage stripped from their documentation. I also noted if I couldn't get them running locally.
Alchemist
measurement
This one appears out of date, the last commit was 5 years ago, and it doesn't seem to run on 1.9.3 for me.
Phys-Units
Quantity
Note that this one states that it is not production ready in the README.
SY
See Boris Stitnickey's answer.
ruby-measurement
ruby-units
Units for Ruby
Unitwise
Van/Unit
Like another poster, I had trouble getting this working. However, you can see Jörg W Mittag's answer for usage.
As the author of Unitwise, it might be obvious that it's my favorite out of the group. I encourage you to at least check it out, though.
尝试一下很棒的Alchemist。
......
Try awesome Alchemist.
......
看看 Tom Sawyer 的 Van/Unit
这是来自主页:
Take a look at Tom Sawyer's Van/Unit
This is from the homepage:
尝试 gem install sy
Try
gem install sy
我无法让货车/单位工作 - 它所报告的只是:
运行时,
我花了一个小时尝试破解van/units 的源,但没有成功。
它所基于的旧版 gem 开箱即用:
http://ruby-units。 rubyforge.org/ruby-units/
I was unable to get Van/units to work - all it reports is:
When running
I spent an hour unsuccessfully attempting to hack the source of van/units.
The older gem on which it is based worked out of the box:
http://ruby-units.rubyforge.org/ruby-units/
vanunits 似乎坏了。我建议尝试
rubyunits (http://ruby-units.rubyforge.org/ruby-units/)
或
测量 (https://github.com/collectiveidea/measurement)
vanunits seems broken. i suggest to try
rubyunits (http://ruby-units.rubyforge.org/ruby-units/)
or
measurements (https://github.com/collectiveidea/measurement)