Class: Qiflib::Date
- Inherits:
-
Object
- Object
- Qiflib::Date
- Defined in:
- lib/qiflib_date.rb
Overview
Instances of this class represent a date from within a qif file, such as ‘D5/24/94’.
Instance Attribute Summary collapse
-
#ccyymmdd ⇒ Object
Returns the value of attribute ccyymmdd.
-
#dd ⇒ Object
Returns the value of attribute dd.
-
#mm ⇒ Object
Returns the value of attribute mm.
-
#string_value ⇒ Object
Returns the value of attribute string_value.
-
#year ⇒ Object
Returns the value of attribute year.
-
#year_mm ⇒ Object
Returns the value of attribute year_mm.
-
#yy ⇒ Object
Returns the value of attribute yy.
Instance Method Summary collapse
-
#initialize(string_value = '') ⇒ Date
constructor
A new instance of Date.
- #to_s ⇒ Object
Constructor Details
#initialize(string_value = '') ⇒ Date
Returns a new instance of Date.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/qiflib_date.rb', line 11 def initialize(string_value='') @cc, @yy, @mm, @dd = '00', '00', '00', '00' @string_value = "#{string_value}".tr('D','') tokens = @string_value.split('/') if (tokens && tokens.size > 2) m = tokens[0].to_i d = tokens[1].to_i y = tokens[2].to_i @yy = tokens[2] y < 50 ? @cc = "20" : @cc = "19" m < 10 ? @mm = "0#{m}" : @mm = "#{m}" d < 10 ? @dd = "0#{d}" : @dd = "#{d}" end @ccyymmdd = "#{@cc}#{@yy}-#{@mm}-#{@dd}" @year = "#{@cc}#{@yy}" @year_mm = "#{@cc}#{@yy}-#{@mm}" end |
Instance Attribute Details
#ccyymmdd ⇒ Object
Returns the value of attribute ccyymmdd.
9 10 11 |
# File 'lib/qiflib_date.rb', line 9 def ccyymmdd @ccyymmdd end |
#dd ⇒ Object
Returns the value of attribute dd.
9 10 11 |
# File 'lib/qiflib_date.rb', line 9 def dd @dd end |
#mm ⇒ Object
Returns the value of attribute mm.
9 10 11 |
# File 'lib/qiflib_date.rb', line 9 def mm @mm end |
#string_value ⇒ Object
Returns the value of attribute string_value.
9 10 11 |
# File 'lib/qiflib_date.rb', line 9 def string_value @string_value end |
#year ⇒ Object
Returns the value of attribute year.
9 10 11 |
# File 'lib/qiflib_date.rb', line 9 def year @year end |
#year_mm ⇒ Object
Returns the value of attribute year_mm.
9 10 11 |
# File 'lib/qiflib_date.rb', line 9 def year_mm @year_mm end |
#yy ⇒ Object
Returns the value of attribute yy.
9 10 11 |
# File 'lib/qiflib_date.rb', line 9 def yy @yy end |
Instance Method Details
#to_s ⇒ Object
29 30 31 |
# File 'lib/qiflib_date.rb', line 29 def to_s @ccyymmdd end |