romanizer 0.0.2

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/romanizer.rb +15 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e5b7463d5a6288c3353c18af1966d17a93d49c0c
4
+ data.tar.gz: a132fe856cb2b2f13e21de66bff0d41feebd6c85
5
+ SHA512:
6
+ metadata.gz: 52a3c6885823697f0348dec1b4c504741c004fc09d9eb81d01079b46d26fce30f37b2d4673e461d0670d4fe01d4b205cb940a1830637e8a608e4f6bd7fb84595
7
+ data.tar.gz: 8e4c14d78bb2815ed5606494fbd73d8a37b4a6f1623791e33ea3d4c1da2974f8b0b5655a3d858de524283f6e7536724400eab4f5606980a0063b305a299bc259
data/lib/romanizer.rb ADDED
@@ -0,0 +1,15 @@
1
+ module Romanize
2
+ letters = %w(M CM D CD C XC L XL X IX V IV I)
3
+ values = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
4
+ LETTERS = letters.zip values
5
+
6
+ def romanize
7
+ n = self
8
+ raise ArgumentError, 'Numeral should be between 1 and 3999' if n < 1 || n > 3999
9
+ LETTERS.map{|l,v| c, n = n.divmod v; l*c}.join ''
10
+ end
11
+ end
12
+
13
+ class Fixnum
14
+ include Romanize
15
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: romanizer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Vitalik Danchenko
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2011-11-27 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A simple romanization gem
14
+ email: vitalik.danchenko@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/romanizer.rb
20
+ homepage: https://github.com/vitalikdanchenko/romanizer
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.4.4
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Romanizer
44
+ test_files: []