Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Make Determinator comparable #80

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/jekyll-last-modified-at/determinator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
module Jekyll
module LastModifiedAt
class Determinator
include Comparable
attr_reader :site_source, :page_path
attr_accessor :format

Expand Down Expand Up @@ -30,7 +31,7 @@ def formatted_last_modified_date
def last_modified_at_time
raise Errno::ENOENT, "#{absolute_path_to_article} does not exist!" unless File.exist? absolute_path_to_article

Time.at(last_modified_at_unix.to_i)
@last_modified_at_time ||= Time.at(last_modified_at_unix.to_i)
end

def last_modified_at_unix
Expand Down Expand Up @@ -61,6 +62,10 @@ def to_liquid
@to_liquid ||= last_modified_at_time
end

def <=>(other)
last_modified_at_time <=> other.last_modified_at_time
end

private

def absolute_path_to_article
Expand Down
Loading