Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Clean up comments and a bit of formatting.

  • Loading branch information...
commit 8608d6c612072609c1b4f935ac0405c6f520f331 1 parent bb6b4ec
@jbarnette jbarnette authored committed
Showing with 17 additions and 8 deletions.
  1. +17 −8 lib/newbase60.rb
View
25 lib/newbase60.rb
@@ -13,7 +13,8 @@ def to_s
@base_60
end
- # converts NewBase60 into base10 integer
+ # Converts into a base 10 integer.
+
def to_i
num = 0
@@ -37,21 +38,25 @@ def to_i
num
end
- # converts NewBase60 string into a Date object
+ # Converts into a Date.
+
def to_date
# HACK this is smelly
# days since epoch * seconds * minutes * hours + timezone
- time = Time.at(Newbase60.new(@base_60).to_i * 60 * 60 * 24 + Time.now.gmtoff.abs)
- # parse the Time object into a Date object
+ time = Time.at(Newbase60.new(@base_60).to_i *
+ 60 * 60 * 24 + Time.now.gmtoff.abs)
+
Date.parse(time.strftime("%Y/%m/%d"))
end
end
class Integer
- # converts base10 integers into NewBase60
+
+ # Converts a base 10 integer into a NewBase60 string.
+
def to_sxg
- return self if zero?
+ return "" if zero?
num = self
sxg = ""
@@ -65,7 +70,9 @@ def to_sxg
sxg
end
- # converts base10 integers into NewBase60 padding with leading zeroes
+ # Converts a base 10 integer into a NewBase60 string, padding with
+ # leading zeroes.
+
def to_sxgf(padding)
num = self
@@ -83,8 +90,10 @@ def to_sxgf(padding)
end
end
-# converts Date object into NewBase60
class Date
+
+ # Converts into a NewBase60 string.
+
def to_sxg
(self - Date.parse("1970/01/01")).to_i.to_sxg
end
Please sign in to comment.
Something went wrong with that request. Please try again.