citeproc 1.0.0.pre8 → 1.0.0.pre9

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,36 @@
1
+ module CiteProc
2
+ # A CiteProc Variable used for numeric values.
3
+ class Number < Variable
4
+
5
+ MAX_ROMAN = 5000
6
+
7
+ FACTORS = [
8
+ ['m', 1000], ['cm', 900], ['d', 500], ['cd', 400],
9
+ ['c', 100], ['xc', 90], ['l', 50], ['xl', 40],
10
+ ['x', 10], ['ix', 9], ['v', 5], ['iv', 4],
11
+ ['i', 1]
12
+ ].freeze
13
+
14
+ class << self
15
+ def pluralize?(string)
16
+ /\S\s*[,&-]\s*\S|\df/ === string
17
+ end
18
+
19
+ # @param number [#to_i] the number to convert
20
+ # @return [String] roman equivalent of the passed-in number
21
+ def romanize(number)
22
+ number, roman = number.to_i, ''
23
+
24
+ return number unless number > 0 || number < MAX_ROMAN
25
+
26
+ FACTORS.each do |code, factor|
27
+ count, number = number.divmod(factor)
28
+ roman << (code * count)
29
+ end
30
+
31
+ roman
32
+ end
33
+ end
34
+ end
35
+
36
+ end
@@ -1,3 +1,3 @@
1
1
  module CiteProc
2
- VERSION = '1.0.0.pre8'.freeze
2
+ VERSION = '1.0.0.pre9'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: citeproc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre8
4
+ version: 1.0.0.pre9
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -126,6 +126,7 @@ files:
126
126
  - lib/citeproc/extensions.rb
127
127
  - lib/citeproc/item.rb
128
128
  - lib/citeproc/names.rb
129
+ - lib/citeproc/number.rb
129
130
  - lib/citeproc/processor.rb
130
131
  - lib/citeproc/selector.rb
131
132
  - lib/citeproc/utilities.rb
@@ -161,7 +162,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
161
162
  version: '0'
162
163
  segments:
163
164
  - 0
164
- hash: 3751303087540435209
165
+ hash: 614723229358903967
165
166
  required_rubygems_version: !ruby/object:Gem::Requirement
166
167
  none: false
167
168
  requirements: