Module: Warpera
- Defined in:
- lib/warpera.rb,
lib/warpera/pair.rb,
lib/warpera/version.rb
Overview
Deals with years possibly spanning different eras
Defined Under Namespace
Classes: Pair
Constant Summary collapse
- VERSION =
"0.1.2"
Class Method Summary collapse
-
.conv_i(year) ⇒ Integer
Convert a string-formatted year into an integer-formatted year.
-
.conv_s(year) ⇒ String
Convert an integer-formatted year into a string-formatted year.
Class Method Details
.conv_i(year) ⇒ Integer
Convert a string-formatted year into an integer-formatted year
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/warpera.rb', line 25 def self.conv_i(year) raise ArgumentError, 'Argument is not a string' unless year.is_a? String info = year.split if info[1] == 'CE' return info[0].to_i else return -1 * info[0].to_i end end |
.conv_s(year) ⇒ String
Convert an integer-formatted year into a string-formatted year
10 11 12 13 14 15 16 17 18 |
# File 'lib/warpera.rb', line 10 def self.conv_s(year) raise ArgumentError, 'Argument is not an integer' unless year.is_a? Integer if year < 0 "#{-1 * year} BCE" else "#{year} CE" end end |