Class: ROF::Filters::DateStamp
- Inherits:
-
ROF::Filter
- Object
- ROF::Filter
- ROF::Filters::DateStamp
- Defined in:
- lib/rof/filters/date_stamp.rb
Overview
Set the upload date to be the date given, provided it doesn’t already exist. Also set the date modified to be the date given. If not given, the date used defaults to the local time on the computer.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ DateStamp
constructor
A new instance of DateStamp.
- #process(obj_list) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ DateStamp
Returns a new instance of DateStamp.
10 11 12 13 14 15 16 17 |
# File 'lib/rof/filters/date_stamp.rb', line 10 def initialize( = {}) @today = .fetch(:as_of) { Date::today } @today_s = if @today.is_a?(Date) @today.strftime('%FZ') else @today.to_s end end |
Instance Method Details
#process(obj_list) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rof/filters/date_stamp.rb', line 19 def process(obj_list) obj_list.map! do |obj| if obj["metadata"].nil? obj["metadata"] = { "@context" => ROF::RdfContext } end # only save the date submitted if it is not already present if obj["metadata"]["dc:dateSubmitted"].nil? obj["metadata"]["dc:dateSubmitted"] = @today_s end # always update the date modified obj["metadata"]["dc:modified"] = @today_s obj end end |