phys-units 0.9.2 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
1
  #
3
2
  # phys/units/unit_class.rb
4
3
  #
@@ -14,11 +13,15 @@ module Phys
14
13
 
15
14
  class << self
16
15
 
16
+ # @visibility private
17
17
  def debug
18
18
  false
19
19
  end
20
20
 
21
- def define(name,expr,v=nil)
21
+ # Define New Unit. Expression is not parsed in this method.
22
+ # @param [String] name Name of this unit.
23
+ # @param [String] expr Expression.
24
+ def define(name,expr)
22
25
  if !(String===name)
23
26
  raise TypeError,"unit name should be string : #{name.inspect}"
24
27
  end
@@ -27,37 +30,47 @@ module Phys
27
30
  if PREFIX[name]
28
31
  warn "prefix definition is overwritten: #{name}" if debug
29
32
  end
30
- PREFIX[name] = self.new(name,expr)
33
+ PREFIX[name] = self.new(expr,name)
31
34
  else
32
35
  if LIST[name]
33
36
  warn "unit definition is overwritten: #{name}" if debug
34
37
  end
35
38
  if expr.kind_of?(String) && /^!/ =~ expr
36
39
  dimless = (expr == "!dimensionless")
37
- LIST[name] = BaseUnit.new(name,dimless,v)
40
+ LIST[name] = BaseUnit.new(name,dimless)
38
41
  else
39
- LIST[name] = self.new(name,expr,v)
42
+ LIST[name] = self.new(expr,name)
40
43
  end
41
44
  end
42
45
  end
43
46
 
47
+
48
+ # Force argument to be Phys::Unit.
49
+ # @return [Phys::Unit]
44
50
  def cast(x)
45
51
  if x.kind_of?(Unit)
46
52
  x
47
53
  else
48
- Unit.new(x)
54
+ Unit.new(x)
49
55
  end
50
56
  end
51
57
 
58
+ # Used in Parser.
59
+ # @visibility private
52
60
  def word(x)
53
61
  find_unit(x) or raise UnitError, "Undefined unit: #{x.inspect}"
54
- #find_unit(x) || define(x,nil)
55
62
  end
56
63
 
64
+ # Searches a registered unit and then Parse as a unit string
65
+ # if not registered.
66
+ # @return [Phys::Unit]
57
67
  def parse(x)
58
68
  find_unit(x) || Unit.cast(Parse.new.parse(x))
59
69
  end
70
+ alias [] parse
60
71
 
72
+ # Searches a registered unit.
73
+ # @return [Phys::Unit, NilClass]
61
74
  def find_unit(x)
62
75
  if Numeric===x
63
76
  Unit.new(x)
@@ -69,13 +82,13 @@ module Phys
69
82
  end
70
83
  end
71
84
 
72
- alias [] find_unit
73
-
85
+ # @visibility private
74
86
  def unit_stem(x)
75
87
  ( /(.{2,}(?:s|z|ch))es$/ =~ x && LIST[$1] ) ||
76
88
  ( /(.{2,})s$/ =~ x && LIST[$1] )
77
89
  end
78
90
 
91
+ # @visibility private
79
92
  def find_prefix(x)
80
93
  Unit.prefix_regex =~ x
81
94
  pre,post = $1,$2
@@ -86,10 +99,12 @@ module Phys
86
99
 
87
100
  #--
88
101
 
89
- def unit_chars
102
+ # @visibility private
103
+ def unit_exclude_chars
90
104
  '\\s*+\\/<=>()\\[\\]^{|}~\\\\'
91
105
  end
92
106
 
107
+ # @visibility private
93
108
  def control_units_dat(var,skip,line)
94
109
  case line
95
110
  when /!\s*end(\w+)/
@@ -114,7 +129,10 @@ module Phys
114
129
  #puts "skip=#{skip.inspect} var=#{var.inspect}"
115
130
  end
116
131
 
117
- def import_units(data=nil,locale=nil)
132
+ # Import Units.dat from text.
133
+ # @param [String] data Text string of Units.dat.
134
+ # @param [String] locale (optional) Set "en_GB" for UK units.
135
+ def import_units(data,locale=nil)
118
136
  str = ""
119
137
  locale ||= ENV['LC_ALL'] || ENV['LANG']
120
138
  if /^(\w+)\./ =~ locale
@@ -9,6 +9,7 @@
9
9
 
10
10
  module Phys
11
11
  class Unit
12
+ # @visibility private
12
13
  module Utils
13
14
  module_function
14
15
 
@@ -75,12 +76,12 @@ module Phys
75
76
  end
76
77
  ud,nd = n_trail_zero(d)
77
78
  if nd > 3
78
- return Rational(n,ud).inspect +
79
+ return Rational(n,ud).inspect +
79
80
  ("*%.0e"%10**(-nd))
80
81
  end
81
82
  un,nn = n_trail_zero(n)
82
83
  if nn > 3
83
- return Rational(un,d).inspect +
84
+ return Rational(un,d).inspect +
84
85
  ("*%.0e"%10**(nn))
85
86
  end
86
87
  end
@@ -1,5 +1,5 @@
1
1
  module Phys
2
2
  class Unit
3
- VERSION = "0.9.2"
3
+ VERSION = "0.9.3"
4
4
  end
5
5
  end
data/misc/mkjpspec.rb ADDED
@@ -0,0 +1,149 @@
1
+ # -*- coding: utf-8 -*-
2
+ $LOAD_PATH.unshift File.dirname(__FILE__)+"/../lib"
3
+ require "phys/units/jp"
4
+
5
+ def main
6
+ puts <<EOL
7
+ # -*- coding: utf-8 -*-
8
+ $LOAD_PATH.unshift File.dirname(__FILE__)
9
+ require "phys/units/jp"
10
+ require "helper"
11
+
12
+ describe "Japanese Units" do
13
+ EOL
14
+
15
+ $data.each_line do |line|
16
+ line.chomp!
17
+ if /([^#]*)\s*#?/ =~ line
18
+ line = $1
19
+ end
20
+ if /^([^\s()\[\]{}!*|\/^#]+)\s+([^#]+)/ =~ line
21
+ name,repr = $1,$2.strip
22
+ name =$1 if /(.*)-$/ =~ name
23
+ #u = Phys::Unit::LIST[name]
24
+ q = Phys::Quantity[1,name]
25
+ u = q.unit
26
+ #p [name,u,q]
27
+ f = "%.9g" % u.conversion_factor
28
+ s = u.base_unit.string_form
29
+ s2 = (s=='') ? "" : ",#{s.inspect}"
30
+ #p [name,name.size,f,s]
31
+ puts <<EOL
32
+ describe Q[1,#{name.inspect}] do
33
+ it {should be_a_quantity_close_to Q[#{f}#{s2}] }
34
+ end
35
+ EOL
36
+ end
37
+ end
38
+
39
+ puts <<EOL
40
+ end
41
+ EOL
42
+ end
43
+
44
+ $data = <<EOL
45
+ # Japanese Number units
46
+ 一- 1
47
+ 二- 2
48
+ 三- 3
49
+ 四- 4
50
+ 五- 5
51
+ 六- 6
52
+ 七- 7
53
+ 八- 8
54
+ 九- 9
55
+ 十- 10
56
+ 百- 10^2
57
+ 千- 10^3
58
+ 万- 10^4
59
+ 億- 10^8
60
+ 兆- 10^12
61
+ 京- 10^16
62
+ 垓- 10^20
63
+ 秭- 10^24
64
+ 秭- 10^24
65
+ 穰- 10^28
66
+ 溝- 10^32
67
+ 澗- 10^36
68
+ 正- 10^40
69
+ 載- 10^44
70
+ 極- 10^48
71
+ 恒河沙- 10^52
72
+ 阿僧祇- 10^56
73
+ 那由他- 10^60
74
+ 不可思議- 10^64
75
+ 無量大数- 10^68
76
+ #
77
+ 割- 1|10
78
+ 分- 1|100
79
+ 厘- 1|1000
80
+ 釐- 1|1000
81
+ 毛- 1|10^4
82
+ 毫- 1|10^4
83
+ 糸- 1|10^4
84
+ 絲- 1|10^4
85
+ 忽- 1|10^5
86
+ 微- 1|10^6
87
+ 繊- 1|10^7
88
+ 沙- 1|10^8
89
+ 塵- 1|10^9
90
+ 埃- 1|10^10
91
+ 渺- 1|10^11
92
+ 漠- 1|10^12
93
+ 模糊- 1|10^13
94
+ 逡巡- 1|10^14
95
+ 須臾- 1|10^15
96
+ 瞬息- 1|10^16
97
+ 弾指- 1|10^17
98
+ 刹那- 1|10^18
99
+ 六徳- 1|10^19
100
+ 虚空- 1|10^20
101
+ 清浄- 1|10^21
102
+ 阿頼耶- 1|10^22
103
+ 阿摩羅- 1|10^23
104
+ 涅槃寂静- 1|10^24
105
+ #
106
+ # Traditional Japanese units (shakkanhou)
107
+ #
108
+ # Japanese Length Measures
109
+ 尺 shaku # =10/33メートル≒0.303 0303メートル
110
+ 寸 1|10 尺
111
+ 里 36 町 # ≒3927.272 727メートル
112
+ 町 60 間 # ≒109.090 909メートル
113
+ 間 6 尺 # ≒1.818 182メートル
114
+ 丈 10 尺 # ≒3.030 303メートル
115
+ 曲尺 尺
116
+ 鯨尺 kujirajaku # 10|8 shaku
117
+ #
118
+ # Japanese Area Measures
119
+ 坪 tsubo # = 400/121平方メートル[3] ≒3.305 785平方メートル
120
+ 畝 30 坪 # ≒99.173 554平方メートル
121
+ 反 10 畝 # ≒991.7355平方メートル
122
+ 段 反 # ≒991.7355平方メートル
123
+ #歩 坪
124
+ #町 10 反 # ≒9917.355平方メートル
125
+ #合 1|10 坪 # ≒0.330 5785平方メートル#
126
+ #勺 1|100 坪 #
127
+ #
128
+ # Japanese architecture is based on a "standard" size of tatami mat.
129
+ 江戸間 edoma # (5.8*2.9) shaku^2
130
+ 京間 kyouma # (6.3*3.15) shaku^2
131
+ 中京間 chuukyouma # (6*3) shaku^2
132
+ 畳 tatami
133
+ #
134
+ # Japanese Volume Measures
135
+ 升 shou # 10合 = 2401/1331リットル ≒1.803 906 837リットル
136
+ 斗 10 升 # ≒ 18.039 068リットル
137
+ 石 10 斗 # ≒ 180.390 684リットル
138
+ 合 1|10 升 # 10勺 ≒0.180 390 684リットル
139
+ 勺 1|10 合
140
+ #
141
+ # Japanese Weight Measures
142
+ 貫 1000 匁 # = 100両 = 3.75キログラム
143
+ 斤 160 匁 # = 600グラム
144
+ 両 10 匁 # = 37.5グラム
145
+ 匁 momme # = 3.75グラム
146
+ #
147
+ EOL
148
+
149
+ main
@@ -0,0 +1,60 @@
1
+ $LOAD_PATH << "./lib"
2
+ require 'phys/units'
3
+
4
+ $debug=false
5
+
6
+ def close_values(a,b)
7
+ (a-b).abs < (a.abs+b.abs)*3e-8
8
+ end
9
+
10
+ puts <<EOL
11
+ $LOAD_PATH.unshift File.dirname(__FILE__)
12
+ require "helper"
13
+
14
+ describe "Unit Conversion" do
15
+ EOL
16
+
17
+ keys = Phys::Unit::LIST.keys
18
+ keys.each do |k,u|
19
+ puts k if $debug
20
+ u = Phys::Unit::LIST[k]
21
+ f = u.conversion_factor
22
+ s = u.base_unit.string_form
23
+ #s = '1' if s==''
24
+ puts "#{k}, #{u.name}, #{u.string_form}, #{u.factor} base: #{f}, #{s}" if $debug
25
+ n = u.name
26
+ if /'/ =~ n
27
+ c = "units "#{n}" '#{s}'"
28
+ puts c if $debug
29
+ next
30
+ else
31
+ c = "units '#{n}' '#{s}'"
32
+ end
33
+ puts c if $debug
34
+ x = `#{c}`
35
+ puts x if $debug
36
+
37
+ if /\* ([\d.e+-]+)\s+\/ ([\d.e+-]+)/m =~ x
38
+ factor = $1
39
+ s2 = (s=='') ? "" : ",#{s.inspect}"
40
+ puts <<EOL
41
+ describe Q[1,#{n.inspect}] do
42
+ it {should be_a_quantity_close_to Q[#{factor}#{s2}] }
43
+ end
44
+ EOL
45
+ factor = factor.to_f
46
+ puts "factor = #{factor} <=> f=#{f} => #{factor.to_f<=>f}" if $debug
47
+ if !close_values(factor, f)
48
+ puts "#{k}, #{u.name}, #{u.string_form}, #{u.factor} base: #{f}, #{s}"
49
+ puts c
50
+ puts x
51
+ puts "factor = #{factor} <=> f=#{f} => #{factor<=>f}"
52
+ puts "diff = #{(factor-f).abs/(factor.abs+f.abs)}"
53
+ puts "--"
54
+ end
55
+ end
56
+ end
57
+
58
+ puts <<EOL
59
+ end
60
+ EOL
data/misc/readme.jp.md ADDED
@@ -0,0 +1,6 @@
1
+ require 'phys/units/jp'
2
+ q = Phys::Quantity
3
+ q[1,"寸"].want("cm") #=> Phys::Quantity[(1/0.33),"cm"]
4
+ q[1,"坪"].want("m^2") #=> Phys::Quantity[(1/0.3025),"m^2"]
5
+ q[1,"升"].want("l") #=> Phys::Quantity[(2401/1331),"l"]
6
+ q[1,"貫"].want("kg") #=> Phys::Quantity[3.75,"kg"]
File without changes
@@ -0,0 +1,256 @@
1
+ # -*- coding: utf-8 -*-
2
+ $LOAD_PATH.unshift File.dirname(__FILE__)
3
+ require "phys/units/jp"
4
+ require "helper"
5
+
6
+ describe "Japanese Units" do
7
+ describe Q[1,"一"] do
8
+ it {should be_a_quantity_close_to Q[1] }
9
+ end
10
+ describe Q[1,"二"] do
11
+ it {should be_a_quantity_close_to Q[2] }
12
+ end
13
+ describe Q[1,"三"] do
14
+ it {should be_a_quantity_close_to Q[3] }
15
+ end
16
+ describe Q[1,"四"] do
17
+ it {should be_a_quantity_close_to Q[4] }
18
+ end
19
+ describe Q[1,"五"] do
20
+ it {should be_a_quantity_close_to Q[5] }
21
+ end
22
+ describe Q[1,"六"] do
23
+ it {should be_a_quantity_close_to Q[6] }
24
+ end
25
+ describe Q[1,"七"] do
26
+ it {should be_a_quantity_close_to Q[7] }
27
+ end
28
+ describe Q[1,"八"] do
29
+ it {should be_a_quantity_close_to Q[8] }
30
+ end
31
+ describe Q[1,"九"] do
32
+ it {should be_a_quantity_close_to Q[9] }
33
+ end
34
+ describe Q[1,"十"] do
35
+ it {should be_a_quantity_close_to Q[10] }
36
+ end
37
+ describe Q[1,"百"] do
38
+ it {should be_a_quantity_close_to Q[100] }
39
+ end
40
+ describe Q[1,"千"] do
41
+ it {should be_a_quantity_close_to Q[1000] }
42
+ end
43
+ describe Q[1,"万"] do
44
+ it {should be_a_quantity_close_to Q[10000] }
45
+ end
46
+ describe Q[1,"億"] do
47
+ it {should be_a_quantity_close_to Q[100000000] }
48
+ end
49
+ describe Q[1,"兆"] do
50
+ it {should be_a_quantity_close_to Q[1e+12] }
51
+ end
52
+ describe Q[1,"京"] do
53
+ it {should be_a_quantity_close_to Q[1e+16] }
54
+ end
55
+ describe Q[1,"垓"] do
56
+ it {should be_a_quantity_close_to Q[1e+20] }
57
+ end
58
+ describe Q[1,"秭"] do
59
+ it {should be_a_quantity_close_to Q[1e+24] }
60
+ end
61
+ describe Q[1,"秭"] do
62
+ it {should be_a_quantity_close_to Q[1e+24] }
63
+ end
64
+ describe Q[1,"穰"] do
65
+ it {should be_a_quantity_close_to Q[1e+28] }
66
+ end
67
+ describe Q[1,"溝"] do
68
+ it {should be_a_quantity_close_to Q[1e+32] }
69
+ end
70
+ describe Q[1,"澗"] do
71
+ it {should be_a_quantity_close_to Q[1e+36] }
72
+ end
73
+ describe Q[1,"正"] do
74
+ it {should be_a_quantity_close_to Q[1e+40] }
75
+ end
76
+ describe Q[1,"載"] do
77
+ it {should be_a_quantity_close_to Q[1e+44] }
78
+ end
79
+ describe Q[1,"極"] do
80
+ it {should be_a_quantity_close_to Q[1e+48] }
81
+ end
82
+ describe Q[1,"恒河沙"] do
83
+ it {should be_a_quantity_close_to Q[1e+52] }
84
+ end
85
+ describe Q[1,"阿僧祇"] do
86
+ it {should be_a_quantity_close_to Q[1e+56] }
87
+ end
88
+ describe Q[1,"那由他"] do
89
+ it {should be_a_quantity_close_to Q[1e+60] }
90
+ end
91
+ describe Q[1,"不可思議"] do
92
+ it {should be_a_quantity_close_to Q[1e+64] }
93
+ end
94
+ describe Q[1,"無量大数"] do
95
+ it {should be_a_quantity_close_to Q[1e+68] }
96
+ end
97
+ describe Q[1,"割"] do
98
+ it {should be_a_quantity_close_to Q[0.1] }
99
+ end
100
+ describe Q[1,"分"] do
101
+ it {should be_a_quantity_close_to Q[0.01] }
102
+ end
103
+ describe Q[1,"厘"] do
104
+ it {should be_a_quantity_close_to Q[0.001] }
105
+ end
106
+ describe Q[1,"釐"] do
107
+ it {should be_a_quantity_close_to Q[0.001] }
108
+ end
109
+ describe Q[1,"毛"] do
110
+ it {should be_a_quantity_close_to Q[0.0001] }
111
+ end
112
+ describe Q[1,"毫"] do
113
+ it {should be_a_quantity_close_to Q[0.0001] }
114
+ end
115
+ describe Q[1,"糸"] do
116
+ it {should be_a_quantity_close_to Q[0.0001] }
117
+ end
118
+ describe Q[1,"絲"] do
119
+ it {should be_a_quantity_close_to Q[0.0001] }
120
+ end
121
+ describe Q[1,"忽"] do
122
+ it {should be_a_quantity_close_to Q[1e-05] }
123
+ end
124
+ describe Q[1,"微"] do
125
+ it {should be_a_quantity_close_to Q[1e-06] }
126
+ end
127
+ describe Q[1,"繊"] do
128
+ it {should be_a_quantity_close_to Q[1e-07] }
129
+ end
130
+ describe Q[1,"沙"] do
131
+ it {should be_a_quantity_close_to Q[1e-08] }
132
+ end
133
+ describe Q[1,"塵"] do
134
+ it {should be_a_quantity_close_to Q[1e-09] }
135
+ end
136
+ describe Q[1,"埃"] do
137
+ it {should be_a_quantity_close_to Q[1e-10] }
138
+ end
139
+ describe Q[1,"渺"] do
140
+ it {should be_a_quantity_close_to Q[1e-11] }
141
+ end
142
+ describe Q[1,"漠"] do
143
+ it {should be_a_quantity_close_to Q[1e-12] }
144
+ end
145
+ describe Q[1,"模糊"] do
146
+ it {should be_a_quantity_close_to Q[1e-13] }
147
+ end
148
+ describe Q[1,"逡巡"] do
149
+ it {should be_a_quantity_close_to Q[1e-14] }
150
+ end
151
+ describe Q[1,"須臾"] do
152
+ it {should be_a_quantity_close_to Q[1e-15] }
153
+ end
154
+ describe Q[1,"瞬息"] do
155
+ it {should be_a_quantity_close_to Q[1e-16] }
156
+ end
157
+ describe Q[1,"弾指"] do
158
+ it {should be_a_quantity_close_to Q[1e-17] }
159
+ end
160
+ describe Q[1,"刹那"] do
161
+ it {should be_a_quantity_close_to Q[1e-18] }
162
+ end
163
+ describe Q[1,"六徳"] do
164
+ it {should be_a_quantity_close_to Q[1e-19] }
165
+ end
166
+ describe Q[1,"虚空"] do
167
+ it {should be_a_quantity_close_to Q[1e-20] }
168
+ end
169
+ describe Q[1,"清浄"] do
170
+ it {should be_a_quantity_close_to Q[1e-21] }
171
+ end
172
+ describe Q[1,"阿頼耶"] do
173
+ it {should be_a_quantity_close_to Q[1e-22] }
174
+ end
175
+ describe Q[1,"阿摩羅"] do
176
+ it {should be_a_quantity_close_to Q[1e-23] }
177
+ end
178
+ describe Q[1,"涅槃寂静"] do
179
+ it {should be_a_quantity_close_to Q[1e-24] }
180
+ end
181
+ describe Q[1,"尺"] do
182
+ it {should be_a_quantity_close_to Q[0.303030303,"m"] }
183
+ end
184
+ describe Q[1,"寸"] do
185
+ it {should be_a_quantity_close_to Q[0.0303030303,"m"] }
186
+ end
187
+ describe Q[1,"里"] do
188
+ it {should be_a_quantity_close_to Q[3927.27273,"m"] }
189
+ end
190
+ describe Q[1,"町"] do
191
+ it {should be_a_quantity_close_to Q[109.090909,"m"] }
192
+ end
193
+ describe Q[1,"間"] do
194
+ it {should be_a_quantity_close_to Q[1.81818182,"m"] }
195
+ end
196
+ describe Q[1,"丈"] do
197
+ it {should be_a_quantity_close_to Q[3.03030303,"m"] }
198
+ end
199
+ describe Q[1,"曲尺"] do
200
+ it {should be_a_quantity_close_to Q[0.303030303,"m"] }
201
+ end
202
+ describe Q[1,"鯨尺"] do
203
+ it {should be_a_quantity_close_to Q[0.378787879,"m"] }
204
+ end
205
+ describe Q[1,"坪"] do
206
+ it {should be_a_quantity_close_to Q[3.30578512,"m^2"] }
207
+ end
208
+ describe Q[1,"畝"] do
209
+ it {should be_a_quantity_close_to Q[99.1735537,"m^2"] }
210
+ end
211
+ describe Q[1,"反"] do
212
+ it {should be_a_quantity_close_to Q[991.735537,"m^2"] }
213
+ end
214
+ describe Q[1,"段"] do
215
+ it {should be_a_quantity_close_to Q[991.735537,"m^2"] }
216
+ end
217
+ describe Q[1,"江戸間"] do
218
+ it {should be_a_quantity_close_to Q[1.54453627,"m^2"] }
219
+ end
220
+ describe Q[1,"京間"] do
221
+ it {should be_a_quantity_close_to Q[1.82231405,"m^2"] }
222
+ end
223
+ describe Q[1,"中京間"] do
224
+ it {should be_a_quantity_close_to Q[1.65289256,"m^2"] }
225
+ end
226
+ describe Q[1,"畳"] do
227
+ it {should be_a_quantity_close_to Q[1.54453627,"m^2"] }
228
+ end
229
+ describe Q[1,"升"] do
230
+ it {should be_a_quantity_close_to Q[0.00180390684,"m^3"] }
231
+ end
232
+ describe Q[1,"斗"] do
233
+ it {should be_a_quantity_close_to Q[0.0180390684,"m^3"] }
234
+ end
235
+ describe Q[1,"石"] do
236
+ it {should be_a_quantity_close_to Q[0.180390684,"m^3"] }
237
+ end
238
+ describe Q[1,"合"] do
239
+ it {should be_a_quantity_close_to Q[0.000180390684,"m^3"] }
240
+ end
241
+ describe Q[1,"勺"] do
242
+ it {should be_a_quantity_close_to Q[1.80390684e-05,"m^3"] }
243
+ end
244
+ describe Q[1,"貫"] do
245
+ it {should be_a_quantity_close_to Q[3.75,"kg"] }
246
+ end
247
+ describe Q[1,"斤"] do
248
+ it {should be_a_quantity_close_to Q[0.6,"kg"] }
249
+ end
250
+ describe Q[1,"両"] do
251
+ it {should be_a_quantity_close_to Q[0.0375,"kg"] }
252
+ end
253
+ describe Q[1,"匁"] do
254
+ it {should be_a_quantity_close_to Q[0.00375,"kg"] }
255
+ end
256
+ end