class Aspire::Object::TimePeriod
Represents the time period covered by a reading list in the Aspire
API
Attributes
active[RW]
@!attribute [rw] active
@return [Boolean] true if the time period is currently active
end_date[RW]
@!attribute [rw] end_date
@return [Date] the end of the time period
start_date[RW]
@!attribute [rw] start_date
@return [Date] the start of the time period
title[RW]
@!attribute [rw] title
@return [String] the title of the time period
Public Class Methods
new(uri, factory, json: nil, ld: nil)
click to toggle source
Initialises a new TimePeriod
instance
Calls superclass method
Aspire::Object::Base::new
# File lib/aspire/object/time_period.rb, line 24 def initialize(uri, factory, json: nil, ld: nil) super(uri, factory) json ||= {} self.active = get_property('active', json) self.end_date = get_date('endDate', json) self.start_date = get_date('startDate', json) self.title = get_property('title', json) end
Public Instance Methods
to_s()
click to toggle source
Returns a string representation of the TimePeriod
instance (the title) @return [String] the string representation of the TimePeriod
instance
# File lib/aspire/object/time_period.rb, line 35 def to_s title.to_s end
year()
click to toggle source
Returns the academic year containing this time period @return [Integer, nil] the academic year, or nil if unspecified
# File lib/aspire/object/time_period.rb, line 41 def year result = title.split('-')[0] result ? result.to_i : nil end