class GEDCOM::DatePart

Constants

NODAY
NOFLAG
NOMONTH
NONE

Flags

NONSTANDARD
NOYEAR
PHRASE
YEARSPAN

Public Class Methods

new(type=GEDCOM_DATE_PARSER::GCTGREGORIAN, flags=NONE, data=nil) click to toggle source
Calls superclass method GEDCOM_DATE_PARSER::GEDDate::new
# File lib/gedcom_ruby/date.rb, line 35
def initialize(type=GEDCOM_DATE_PARSER::GCTGREGORIAN, flags=NONE, data=nil)
  super( type, flags, data )
end

Public Instance Methods

<=>( dp ) click to toggle source
# File lib/gedcom_ruby/date.rb, line 101
def <=>( dp )
  return -1 if has_year? and !dp.has_year?
  return 1 if !has_year? and dp.has_year?

  if has_year? and dp.has_year?
    rc = ( year <=> dp.year )
    return rc unless rc == 0
  end

  return -1 if dp.has_month? and !dp.has_month?
  return 1 if !dp.has_month? and dp.has_month?

  if has_month? and dp.has_month?
    rc = ( month <=> dp.month )
    return rc unless rc == 0
  end

  return -1 if dp.has_day? and !dp.has_day?
  return 1 if !dp.has_day? and dp.has_day?

  if has_day? and dp.has_day?
    rc = ( day <=> dp.day )
    return rc unless rc == 0
  end

  return 0
end
calendar() click to toggle source
# File lib/gedcom_ruby/date.rb, line 39
def calendar
  @type
end
compliance() click to toggle source
# File lib/gedcom_ruby/date.rb, line 43
def compliance
  @flags
end
day() click to toggle source
# File lib/gedcom_ruby/date.rb, line 72
def day
  raise DateFormatException, "date has no day" if (@flags == PHRASE || (@data.flags & NODAY) != 0)
  @data.day
end
epoch() click to toggle source
# File lib/gedcom_ruby/date.rb, line 92
def epoch
  raise DateFormatException, "only gregorian dates have epoch" if ( @flags == PHRASE || @type != GEDCOM_DATE_PARSER::GCTGREGORIAN )
  return (( @data.adbc == GEDCOM_DATE_PARSER::GEDADBCBC ) ? "BC" : "AD" )
end
has_day?() click to toggle source
# File lib/gedcom_ruby/date.rb, line 52
def has_day?
  return false if ( @flags == PHRASE )
  return ((@data.flags & NODAY) != 0 ? false : true)
end
has_month?() click to toggle source
# File lib/gedcom_ruby/date.rb, line 57
def has_month?
  return false if ( @flags == PHRASE )
  return ((@data.flags & NOMONTH) != 0 ? false : true)
end
has_year?() click to toggle source
# File lib/gedcom_ruby/date.rb, line 62
def has_year?
  return false if ( @flags == PHRASE )
  return ((@data.flags & NOYEAR) != 0 ? false : true)
end
has_year_span?() click to toggle source
# File lib/gedcom_ruby/date.rb, line 67
def has_year_span?
  return false if ( @flags == PHRASE )
  return ((@data.flags & YEARSPAN) != 0 ? true : false)
end
month() click to toggle source
# File lib/gedcom_ruby/date.rb, line 77
def month
  raise DateFormatException, "date has no month" if (@flags == PHRASE || (@data.flags & NOMONTH) != 0)
  @data.month
end
phrase() click to toggle source
# File lib/gedcom_ruby/date.rb, line 47
def phrase
  raise DateFormatException if( @flags != PHRASE )
  @data
end
to_s() click to toggle source
# File lib/gedcom_ruby/date.rb, line 97
def to_s
  GEDCOM_DATE_PARSER::DateParser.build_gedcom_date_part_string( self )
end
to_year() click to toggle source
# File lib/gedcom_ruby/date.rb, line 87
def to_year
  raise DateFormatException, "date has no year span" if (@flags == PHRASE || (@data.flags & YEARSPAN) == 0)
  @data.year2
end
year() click to toggle source
# File lib/gedcom_ruby/date.rb, line 82
def year
  raise DateFormatException, "date has no year" if (@flags == PHRASE || (@data.flags & NOYEAR) != 0)
  @data.year
end