class Jekyll::GalleryImage

Attributes

name[RW]
path[RW]

Public Class Methods

new(name, base) click to toggle source
# File lib/jekyll-gallery-generator.rb, line 16
def initialize(name, base)
  @name = name
  @path = File.join(base, name)
end

Public Instance Methods

<=>(b) click to toggle source
# File lib/jekyll-gallery-generator.rb, line 21
def <=>(b)
  cmp = @date_time <=> b.date_time
  return cmp == 0 ? @name <=> b.name : cmp
end
date_time() click to toggle source
# File lib/jekyll-gallery-generator.rb, line 26
def date_time
  return @date_time if defined? @date_time
  begin
    @date_time = self.exif.date_time.to_i
  rescue Exception => e
    @date_time = 0
  end
  return @date_time
end
exif() click to toggle source
# File lib/jekyll-gallery-generator.rb, line 36
def exif
  return @exif if defined? @exif
  @exif = nil
  begin
    @exif = EXIFR::JPEG.new(@path)
  rescue EXIFR::MalformedJPEG
    puts "No EXIF data in #{@path}"
  rescue Exception => e
    puts "Error reading EXIF data for #{@path}: #{e}"
  end
  return @exif
end
to_liquid() click to toggle source
# File lib/jekyll-gallery-generator.rb, line 53
def to_liquid
  # Liquid hates symbol keys. Gotta stringify them
  return {
    'name' => @name,
    'src' => @name,
    'date_time' => @date_time,
    'exif' => @exif && @exif.to_hash.collect{|k,v| [k.to_s, v]}.to_h,
  }
end
to_s() click to toggle source
# File lib/jekyll-gallery-generator.rb, line 49
def to_s
  return @name
end