- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我知道 Rails 有一些用于日期和时间管理的好 helper 。是否有一个已经在运行的项目包含或合并了用于标准单位及其转换的干净的 DSL?任何具有在两个系统的基本长度和重量单位之间进行转换的助手的项目都可以工作。谢谢!
最佳答案
哇,比我想象的要多很多。这是我认为的完整列表,按字母顺序排列,示例用法从他们的文档中删除。我还注意到我是否无法让它们在本地运行。
require 'alchemist'
Alchemist.setup
8.miles.to.meters
10.kilometers + 1.mile # 11.609344 kilometers
这个看起来已经过时了,最后一次提交是 5 年前的,对我来说它似乎不能在 1.9.3 上运行。
include Measurement::Length
Inch.new(12).to_centimeters # => #<Measurement::Length::Centimeter:0x173c2b4 @units=30.48>
require "phys/units"
Q = Phys::Quantity
U = Phys::Unit
Q[1.23,'km'] + Q[4.56,'m'] #=> Phys::Quantity[1.23456,'km']
Q[123,'mile'] / Q[2,'hr'] #=> Phys::Quantity[61,'mile/hr']
Q[61,'miles/hr'].want('m/s') #=> Phys::Quantity[27.26944,'m/s']
Q[1.0,'are'] == Q[10,'m']**2 #=> true
请注意,这个声明在 README 中尚未准备好生产。
require 'quantity/all'
1.meter #=> 1 meter
1.meter.to_feet #=> 3.28083... foot
c = 299792458.meters / 1.second #=> 299792458 meter/second
newton = 1.meter * 1.kilogram / 1.second**2 #=> 1 meter*kilogram/second^2
newton.to_feet #=> 3.28083989501312 foot*kilogram/second^2
newton.convert(:feet) #=> 3.28083989501312 foot*kilogram/second^2
jerk_newton = newton / 1.second #=> 1 meter*kilogram/second^3
jerk_newton * 1.second == newton #=> true
require 'ruby-measurement'
measurement = Measurement.parse('3 feet') # => 3.0 ft.
measurement.convert_to(:yards) # => 1.0 yd.
measurement.convert_to(:in) # => 36.0 in.
measurement.convert_to(:inches) # => 36.0 in.
measurement1 = Measurement.parse('3 feet') # => 3.0 ft.
measurement2 = Measurement.parse('6 inch') # => 6.0 in.
measurement1 + measurement2 # => 3.5 ft.
require 'ruby-units'
unit = Unit("mm") # unit only (defaults to a scalar of 1)
unit = Unit("1 mm") # create a simple unit
unit = Unit("1 kg*m^2/s^2") # complex unit
unit1 =~ unit2 # true if units are compatible
unit1.compatible?(unit2) # true if units are compatible
unit1 = unit >> "ft" # convert to 'feet'
unit3 = unit1 + unit2 # resulting object will have the units of unit1
unit1 === unit2 # true if units and quantity are the same, even if 'equivalent' by <=>
unit.convert_to('ft') # convert
(unit1 + unit2).convert_to('ft') # converts result to 'ft'
require 'units'
three_meters = 3.meters
two_meters = 2.m
one_inch = 1.inch
3.meters.to_inches # => 118.1103 inch
10.inches.to_mm # => 254.0 millimeter
require 'unitwise/ext'
1.yard == (1.foot * 3) # => true
1.quart < 1.liter # => true
2.meter + 3.inch - 1.yard # => <Unitwise::Measurement 1.1618 meter>
1.convert_to('kg.m2/s2') == 1.joule # => true
(20.kg * 9.8.convert_to('m/s2')).to_pound_force # => <Unitwise::Measurement 44.06255284754326 pound_force>
(300.horsepower * 60.second).to_calorie # => <Unitwise::Measurement 3208077.8414151203 calorie>
与另一位发帖人一样,我无法正常工作。不过使用方法可以看Jörg W Mittag's answer。
作为 Unitwise 的作者,很明显它是我最喜欢的。不过,我鼓励您至少检查一下。
关于ruby - 用于在 Ruby 中转换物理单位(千克、磅)的库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4235764/
我有 2 张 table ; item_in(item_id,unit) item_out(item_id,unit) 现在假设我想知道为每个项目插入了多少个单元,我只是查询 select sum(u
API 浏览器中有 3 个速率限制类别: 如果我使用 Youtube 数据 API(其中跟随 implicit OAuth grant flow)创建客户端 Web 应用程序,我是否仍被限制为总共 1
我正在使用一个 postgresql 表,该表包含许多带有 GEOMETRY(Point, 4326) 的行。使用 ST_SnapToGrid 函数和 DISTINCT 选择,我只根据显示的 map
我对 C++ 和 Cppunit 都很陌生。我正在尝试编译一个小的 cppunit 测试。但是,我没有成功。 qwerty@qwerty:~/chessgame/src$ g++ -Wall Coor
我注意到 REM 单位可用于元素的大小,而不仅仅是字体大小。并且对 HTML 字体大小属性非常有用。 html { font-size:1vw } @media all and (max-width:
我试图在 Shapely 中找到线串的长度(以米为单位),但似乎无法达到预期的结果。几乎可以肯定我在坐标系方面犯了一些错误,但我无法弄清楚。 这是单行的一些简化代码: from shapely.geo
对于大量的物种数据集,我试图计算给定月份集的圆形平均值,例如对于从 3 月到 7 月开花的物种,我想知道开花的平均月份(即 5 月),以及围绕平均值的方差。 给定月份是循环的,因此 12 月到 2 月
我还应该在单元测试中释放对象吗? 我注意到在Apple的“iPhoneUnitTests”示例项目中,设置方法中的对象是[[object alloc] init],但从未在单元测试中的任何地方发布?
我目前正在使用 OpenGL 进行开发,并使用米作为我自己的单位,即 20 厘米宽的三角形为 0.2。然而 OpenGL 似乎对这些数字进行了舍入,最终的形状并不完全符合我的意愿。这在 OpenGL
我的问题与对信号进行频谱分析或将信号放入 FFT 并使用合适的数值包解释结果的物理意义有关, 具体: 获取一个信号,例如时变电压 v(t) 将其放入 FFT 中(您将得到复数序列) 现在取模 (abs
在深入研究代码后,我意识到 Fabricjs Text 对象的 fontSize 是在 PIXELS 中测量的。在我的项目中,有时我需要使用点而不是像素。 当指定单位时,我只在代码中找到一个位置,此片
在我的应用程序中,我尝试使用,RentModel.find({prop_location : { $near : [msg.lat, msg.lng],$maxDistance : 500}},函数(
我正在开发我的第一个 LibGdx (Scene2d + Box2d) 游戏,这对我来说是一个全新的领域,但仍然对一些事情感到有点困惑,尤其是关于单位。已经看到了几种不同的处理方法,但仍然不确定哪种方
我正在寻找一个 MySQL 查询(子查询很好),它将以下列格式获取过去一年中每个订单的单位分布: units_per_order | number_of_orders |
我正在使用 Highcharts生成折线图。 我遇到了 numberFormat 的问题: var test = 15975000; numberFormat(test, 0,',','.'); 结果
我正在尝试创建一些用户定义的类型来表示单位,以便我可以强类型化函数参数。例如,长度为毫米,速度为毫米每秒,加速度为毫米每秒等。 到目前为止我已经这样做了: template struct Value
谁能解释一下最低精度的 ULP 单位?我有如下定义,但还是不清楚 “表示分数时的误差大小与存储的数字大小成正比。ULP 或最小精度单位定义了存储数字时可以获得的最大误差。存储的数字越大,ULP 越大”
我有一张卡片图像,我需要重复它 30 次,每次我想申请一张特定卡片的左侧位置时,它会与卡片重叠,然后再停留在一副牌的位置上。 问题是,当我将左侧位置应用于图像卡片时,它会将相同的左侧位置应用于所有卡片
有没有办法用php代码更改每个滚动条的大小。 说明:当我向下滚动时,它会下降x(50~)像素,我想将x改为20。 编辑:这是我的代码。。。 Excel "; $i=1; wh
我不知道下面的想法是否可行或不能概括它,但我想将每个计算值四舍五入到 100 单位四舍五入。 例子: double x; int x_final; ... if (x<400) x_final=400
我是一名优秀的程序员,十分优秀!