rdoba 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: de3915947273d92b53e9c92e437616e80e0c9c65
4
- data.tar.gz: 872ef7f8461a8d8f68f7fb96d9def4a29a2e1cfd
3
+ metadata.gz: 21b7bd86452065d58b56be74cca5bd920b9ad7b8
4
+ data.tar.gz: b9658c828d4c4f42e00614932bb405422dde8459
5
5
  SHA512:
6
- metadata.gz: c87fdbd82c384dd768951fc3f15721d6f6f5655b349d05969e3d4788e368fc5224a221945031cf64524f6b2b96290d63548b96f04512c5ddeb9bf4df3900754a
7
- data.tar.gz: 6019bb189d423e62551fc1e198ee84d4c4d7cc4ccc1fff8841c2696eb0b10309844f56ea77eec405aa81037ec654317dfe5b6b5597d95d66bade188c13b28c60
6
+ metadata.gz: 279afcc056e1e77569850f5b31e1ed71269ccdfd1d9ec6b1e0b3d8d5e76f3c9a06c9273bfbe3e9e98919c41ede0a64852ef9c90a679233c3f493732b4ffcd0a2
7
+ data.tar.gz: 39a442d51818b1ddd96457f6ca122a2085237971f6a3751dc76cb215020273d923fc5c9f31ff7da292b2d0a135e259e32e60199bf446501b9b38dbbfd60562a3
data/Rakefile CHANGED
@@ -55,8 +55,8 @@ Cucumber::Rake::Task.new
55
55
  # task :default => :make
56
56
  #end
57
57
  #
58
- #task(:default).clear
59
- #task :default => :cucumber
58
+ task(:default).clear
59
+ task :default => :cucumber
60
60
  #task :codeclimate => :cucumber
61
61
  #task :all => [ :bundleup, :up, :cucumber, :'gem:make', :distclean ]
62
62
  #task :build => [ :bundleup, :up, :cucumber, :rdoc,
@@ -1,3 +1,3 @@
1
1
  module Rdoba
2
- VERSION = "0.9.2"
2
+ VERSION = "0.9.3"
3
3
  end
@@ -1,45 +1,43 @@
1
1
  #!/usr/bin/ruby -KU
2
2
 
3
3
  class Numeric
4
- Roman = { 1 => 'I', 4 => 'IV', 5 => 'V', 9 => 'IX', 10 => 'X', 40 => 'XL', 50 => 'L',
5
- 90 => 'XC', 100 => 'C', 400 => 'CD', 500 => 'D', 900 => 'CM', 1000 => 'M' }
6
- Romani = Roman.keys.sort
4
+ Roman = { 1 => 'I',
5
+ 4 => 'IV',
6
+ 5 => 'V',
7
+ 9 => 'IX',
8
+ 10 => 'X',
9
+ 40 => 'XL',
10
+ 50 => 'L',
11
+ 90 => 'XC',
12
+ 100 => 'C',
13
+ 400 => 'CD',
14
+ 500 => 'D',
15
+ 900 => 'CM',
16
+ 1000 => 'M' }
17
+ RomanNumbers = Roman.keys.sort
18
+ RomanToInteger = Roman.invert
19
+ RomanDigits = RomanToInteger.keys.sort { |x,y| x.size < y.size ? 1 : x.size > y.size ? -1 : x <=> y }
7
20
 
8
- def to_rom
9
- res = ''
10
- num = self
11
- i = Romani.size - 1
21
+ def to_rom
22
+ res = ''
23
+ num = self
24
+ i = RomanNumbers.size - 1
12
25
 
13
- while num > 0
14
- if num >= Romani[i]
15
- res << Roman[Romani[i]]
16
- num -= Romani[i]
17
- else
18
- i -= 1
19
- end
20
- end
21
- res
22
- end
23
-
24
- end
26
+ while num > 0
27
+ if num >= RomanNumbers[ i ]
28
+ res << Roman[ RomanNumbers[ i ] ]
29
+ num -= RomanNumbers[ i ]
30
+ else
31
+ i -= 1 ;end;end
32
+ res ;end;end
25
33
 
26
34
  class String
27
- def rom
28
- h = Numeric::Roman.reverse
29
- keys = h.keys.sort do |x,y| x.size < y.size ? 1 : x.size > y.size ? -1 : x <=> y end
30
- str = self.upcase
31
- res = 0
32
- while str and not str.empty?
33
- raise "Invalid roman number" if (keys.each do |key|
34
- if str =~ /^#{key}(.*)/
35
- str = $1
36
- res += h[key]
37
- break nil
38
- end
39
- end)
40
- end
41
- res
42
- end
43
- end
44
-
35
+ RomanRe = /(#{Numeric::RomanDigits.join("|")})/
45
36
 
37
+ def rom
38
+ numbers = self.upcase.scan(RomanRe).flatten.map { |x| Numeric::RomanToInteger[x] }
39
+ numbers.sort do |x, y|
40
+ if x < y
41
+ raise "Invalid roman number" ;end
42
+ 0 ;end
43
+ numbers.sum ;end;end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdoba
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Малъ Скрылёвъ (Malo Skrylevo)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-13 00:00:00.000000000 Z
11
+ date: 2017-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simplecov
@@ -161,50 +161,7 @@ extra_rdoc_files:
161
161
  - README.md
162
162
  - LICENSE
163
163
  - CHANGES.md
164
- - html/css/fonts.css
165
- - html/css/rdoc.css
166
164
  - html/.keep
167
- - html/images/wrench_orange.png
168
- - html/images/plugin.png
169
- - html/images/package.png
170
- - html/images/add.png
171
- - html/images/page_white_text.png
172
- - html/images/arrow_up.png
173
- - html/images/wrench.png
174
- - html/images/transparent.png
175
- - html/images/bullet_toggle_minus.png
176
- - html/images/ruby.png
177
- - html/images/macFFBgHack.png
178
- - html/images/loadingAnimation.gif
179
- - html/images/tag_blue.png
180
- - html/images/date.png
181
- - html/images/find.png
182
- - html/images/bullet_toggle_plus.png
183
- - html/images/bullet_black.png
184
- - html/images/brick_link.png
185
- - html/images/bug.png
186
- - html/images/page_green.png
187
- - html/images/tag_green.png
188
- - html/images/page_white_width.png
189
- - html/images/zoom.png
190
- - html/images/brick.png
191
- - html/images/delete.png
192
- - html/created.rid
193
- - html/js/darkfish.js
194
- - html/js/search.js
195
- - html/js/navigation.js
196
- - html/js/navigation.js.gz
197
- - html/js/search_index.js
198
- - html/js/jquery.js
199
- - html/js/searcher.js
200
- - html/js/search_index.js.gz
201
- - html/js/searcher.js.gz
202
- - html/fonts/Lato-LightItalic.ttf
203
- - html/fonts/SourceCodePro-Bold.ttf
204
- - html/fonts/Lato-Regular.ttf
205
- - html/fonts/SourceCodePro-Regular.ttf
206
- - html/fonts/Lato-Light.ttf
207
- - html/fonts/Lato-RegularItalic.ttf
208
165
  files:
209
166
  - ".document"
210
167
  - ".gitignore"
@@ -224,49 +181,6 @@ files:
224
181
  - features/support/fulltest_as_self.rb.in
225
182
  - features/support/mixin_support.rb
226
183
  - html/.keep
227
- - html/created.rid
228
- - html/css/fonts.css
229
- - html/css/rdoc.css
230
- - html/fonts/Lato-Light.ttf
231
- - html/fonts/Lato-LightItalic.ttf
232
- - html/fonts/Lato-Regular.ttf
233
- - html/fonts/Lato-RegularItalic.ttf
234
- - html/fonts/SourceCodePro-Bold.ttf
235
- - html/fonts/SourceCodePro-Regular.ttf
236
- - html/images/add.png
237
- - html/images/arrow_up.png
238
- - html/images/brick.png
239
- - html/images/brick_link.png
240
- - html/images/bug.png
241
- - html/images/bullet_black.png
242
- - html/images/bullet_toggle_minus.png
243
- - html/images/bullet_toggle_plus.png
244
- - html/images/date.png
245
- - html/images/delete.png
246
- - html/images/find.png
247
- - html/images/loadingAnimation.gif
248
- - html/images/macFFBgHack.png
249
- - html/images/package.png
250
- - html/images/page_green.png
251
- - html/images/page_white_text.png
252
- - html/images/page_white_width.png
253
- - html/images/plugin.png
254
- - html/images/ruby.png
255
- - html/images/tag_blue.png
256
- - html/images/tag_green.png
257
- - html/images/transparent.png
258
- - html/images/wrench.png
259
- - html/images/wrench_orange.png
260
- - html/images/zoom.png
261
- - html/js/darkfish.js
262
- - html/js/jquery.js
263
- - html/js/navigation.js
264
- - html/js/navigation.js.gz
265
- - html/js/search.js
266
- - html/js/search_index.js
267
- - html/js/search_index.js.gz
268
- - html/js/searcher.js
269
- - html/js/searcher.js.gz
270
184
  - lib/rdoba.rb
271
185
  - lib/rdoba/_version_.rb
272
186
  - lib/rdoba/a.rb