cousin_roman 1.0.7 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d4d7fcee5c6d30a502f4b7bbf78d944a8c6e3d02
4
- data.tar.gz: 09980720de8dbdfd533450dcf8d72b114a925762
3
+ metadata.gz: bd6c304cffc6a79b1ac5ab743f49a368a4e4002a
4
+ data.tar.gz: cdc85045a0dda001f293a225456c2ea7b9f7da88
5
5
  SHA512:
6
- metadata.gz: 00c5f147a205cd9498bb1a84e19b546174e61f3d72fff381cf3fd92d106d1b0e24a196c092da8df5b63ce2eb121551b0ecd5b2817121f4edc7d55769d789af3d
7
- data.tar.gz: e13de4db11e56b467f4dc2c90b68c1b1042764a5b99d3d05f9ea2b2c6c9259131c51012e404b3519a6506b53da55c4e635b5bf1740df7d1cb755f3857896f7b8
6
+ metadata.gz: 6a2a97591dcee49decf72fd77e94267170663cc5cc79b186fd62a795eabbd88bd214c4f35d9ee520886149168b9b5507cb06c44da8ac2e4b59562df3b49c744e
7
+ data.tar.gz: 32919249c36a26eb13058a1db4c894d6c60507d34e684da14e040524f8637fcdf78217913b402d1a4d1b08fbf8920dc227fa1c8c4a62d9afe5f3d48902d2a1ef
@@ -11,11 +11,8 @@ module CousinRoman
11
11
  end
12
12
 
13
13
  def to_roman!(arabian)
14
- if valid? arabian
15
- convert arabian
16
- else
17
- raise TypeError, 'not a valid roman number'
18
- end
14
+ valid? arabian or raise TypeError, 'not a valid roman number'
15
+ convert arabian
19
16
  end
20
17
 
21
18
  def convert(number)
@@ -1,9 +1,15 @@
1
- class Integer
2
- def to_roman
3
- CousinRoman::Arabian.to_roman(self)
4
- end
1
+ module CousinRoman
2
+ module IntegerExtension
3
+ def to_roman
4
+ CousinRoman::Arabian.to_roman(self)
5
+ end
5
6
 
6
- def to_roman!
7
- CousinRoman::Arabian.to_roman!(self)
7
+ def to_roman!
8
+ CousinRoman::Arabian.to_roman!(self)
9
+ end
8
10
  end
9
11
  end
12
+
13
+ class Integer
14
+ include CousinRoman::IntegerExtension
15
+ end
@@ -21,8 +21,7 @@ module CousinRoman
21
21
  compound = braketize_value_of SUBTRACTIVES
22
22
  singular = braketize_value_of ONES.merge(FIVES)
23
23
 
24
- compound.each { |literal, val| intermediate.gsub!(literal, val) }
25
- singular.each { |literal, val| intermediate.gsub!(literal, val) }
24
+ [compound, singular].each { |factors| factors.each { |literal, val| intermediate.gsub!(literal, val) } }
26
25
 
27
26
  intermediate.scan(/\((\d*)\)/).reduce(0) do |sum, term|
28
27
  sum + term.first.to_i
@@ -36,11 +35,8 @@ module CousinRoman
36
35
 
37
36
  def to_arabian!(number)
38
37
  clean = number.strip
39
- if valid? clean
40
- convert clean
41
- else
42
- raise TypeError, 'not a valid roman number'
43
- end
38
+ valid? clean or raise TypeError, 'not a valid roman number'
39
+ convert clean
44
40
  end
45
41
 
46
42
  def roman_regex
@@ -1,9 +1,15 @@
1
- class String
2
- def to_arabian
3
- CousinRoman::Roman.to_arabian(self)
4
- end
1
+ module CousinRoman
2
+ module StringExtension
3
+ def to_arabian
4
+ CousinRoman::Roman.to_arabian(self)
5
+ end
5
6
 
6
- def to_arabian!
7
- CousinRoman::Roman.to_arabian!(self)
7
+ def to_arabian!
8
+ CousinRoman::Roman.to_arabian!(self)
9
+ end
8
10
  end
9
11
  end
12
+
13
+ class String
14
+ include CousinRoman::StringExtension
15
+ end
@@ -1,3 +1,3 @@
1
1
  module CousinRoman
2
- VERSION = "1.0.7"
2
+ VERSION = "1.0.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cousin_roman
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artem Pyanykh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-19 00:00:00.000000000 Z
11
+ date: 2013-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  version: '0'
99
99
  requirements: []
100
100
  rubyforge_project:
101
- rubygems_version: 2.1.8
101
+ rubygems_version: 2.0.3
102
102
  signing_key:
103
103
  specification_version: 4
104
104
  summary: Convert Roman numerals to Integers and vice versa