Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Changed class name from new_base_60 to NewBase60

  • Loading branch information...
commit b175d3b20bc47640d44944207e5a64fd1aa8be2a 1 parent 8a70522
@veganstraightedge authored
Showing with 19 additions and 13 deletions.
  1. +6 −0 CHANGELOG.rdoc
  2. +6 −6 lib/new_base_60.rb
  3. +7 −7 test/test_new_base_60.rb
View
6 CHANGELOG.rdoc
@@ -1,3 +1,9 @@
+=== 1.0.4 / 2011-02-15
+
+* 1 minor enhancement
+
+ * Changed class name from new_base_60 to NewBase60
+
=== 1.0.3 / 2010-11-16
* 1 minor enhancement
View
12 lib/new_base_60.rb
@@ -1,7 +1,7 @@
require "date"
require "time"
-class New_base_60
+class NewBase60
VERSION = '1.0.3'
VOCABULARY = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ_abcdefghijkmnopqrstuvwxyz"
@@ -41,7 +41,7 @@ def to_i
def to_date
# HACK this is smelly
# days since epoch * seconds * minutes * hours + timezone
- time = Time.at(New_base_60.new(@base_60).to_i *
+ time = Time.at(NewBase60.new(@base_60).to_i *
60 * 60 * 24 + Time.now.gmtoff.abs)
Date.parse(time.strftime("%Y/%m/%d"))
@@ -49,7 +49,7 @@ def to_date
end
class Integer
- # Converts a base 10 integer into a New_base_60 string.
+ # Converts a base 10 integer into a NewBase60 string.
def to_sxg
return "" if zero?
@@ -58,14 +58,14 @@ def to_sxg
while num > 0 do
mod = num % 60
- sxg = "#{New_base_60::VOCABULARY[mod,1]}#{sxg}"
+ sxg = "#{NewBase60::VOCABULARY[mod,1]}#{sxg}"
num = (num - mod) / 60
end
sxg
end
- # Converts a base 10 integer into a New_base_60 string,
+ # Converts a base 10 integer into a NewBase60 string,
# padding with leading zeroes.
def to_sxgf(padding)
num = self
@@ -85,7 +85,7 @@ def to_sxgf(padding)
end
class Date
- # Converts into a New_base_60 string.
+ # Converts into a NewBase60 string.
def to_sxg
(self - Date.parse("1970/01/01")).to_i.to_sxg
end
View
14 test/test_new_base_60.rb
@@ -1,20 +1,20 @@
require "test/unit"
require "new_base_60"
-class TestNew_base_60 < Test::Unit::TestCase
+class TestNewBase60 < Test::Unit::TestCase
def test_base60_to_base10
- assert_equal New_base_60.new("464").to_i, 14764
- assert_not_equal New_base_60.new("464").to_i, 12345
+ assert_equal NewBase60.new("464").to_i, 14764
+ assert_not_equal NewBase60.new("464").to_i, 12345
end
def test_base60_to_date
- assert_equal New_base_60.new("464").to_date, Date.parse("2010/06/04")
- assert_not_equal New_base_60.new("464").to_date, Date.parse("2010/06/05")
+ assert_equal NewBase60.new("464").to_date, Date.parse("2010/06/04")
+ assert_not_equal NewBase60.new("464").to_date, Date.parse("2010/06/05")
end
def test_date_to_base60
- assert_equal Date.parse("2010/06/04").to_sxg, New_base_60.new("464").to_s
- assert_not_equal Date.parse("2010/06/05").to_sxg, New_base_60.new("464")
+ assert_equal Date.parse("2010/06/04").to_sxg, NewBase60.new("464").to_s
+ assert_not_equal Date.parse("2010/06/05").to_sxg, NewBase60.new("464")
end
def test_base10_to_base60
Please sign in to comment.
Something went wrong with that request. Please try again.