lib/osm/term.rb in osm-0.0.5 vs lib/osm/term.rb in osm-0.0.6
- old
+ new
@@ -1,10 +1,20 @@
module Osm
class Term
attr_reader :id, :section_id, :name, :start, :end
+ # @!attribute [r] id
+ # @return [FixNum] the id for the term
+ # @!attribute [r] section_id
+ # @return [FixNum] the section the term belongs to
+ # @!attribute [r] name
+ # @return [FixNum] the name of the term
+ # @!attribute [r] start
+ # @return [Date] when the term starts
+ # @!attribute [r] end
+ # @return [Date] when the term ends
# Initialize a new Term using the hash returned by the API call
# @param data the hash of data for the object returned by the API
def initialize(data)
@id = Osm::to_i_or_nil(data['termid'])
@@ -13,43 +23,43 @@
@start = Osm::parse_date(data['startdate'])
@end = Osm::parse_date(data['enddate'])
end
# Determine if the term is completly before the passed date
- # @param date
- # @returns true if the term is completly before the passed date
+ # @param [Date] date
+ # @return [Boolean] if the term is completly before the passed date
def before?(date)
return @end < date.to_date
end
# Determine if the term is completly after the passed date
- # @param date
- # @returns true if the term is completly after the passed date
+ # @param [Date] date
+ # @return [Boolean] if the term is completly after the passed date
def after?(date)
return @start > date.to_date
end
# Determine if the term is in the future
- # @returns true if the term starts after today
+ # @return [Boolean] if the term starts after today
def future?
return @start > Date.today
end
# Determine if the term is in the past
- # @returns true if the term finished before today
+ # @return [Boolean] if the term finished before today
def past?
return @end < Date.today
end
# Determine if the term is current
- # @returns true if the term started before today and finishes after today
+ # @return [Boolean] if the term started before today and finishes after today
def current?
return (@start <= Date.today) && (@end >= Date.today)
end
# Determine if the provided date is within the term
- # @param date the date to test
- # @returns true if the term started before the date and finishes after the date
+ # @param [Date] date the date to test
+ # @return [Boolean] if the term started before the date and finishes after the date
def contains_date?(date)
return (@start <= date) && (@end >= date)
end
def <=>(another_term)