Class: Jekyll::GalleryImage
- Inherits:
-
Object
- Object
- Jekyll::GalleryImage
- Includes:
- Comparable
- Defined in:
- lib/jekyll-gallery-generator.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #<=>(b) ⇒ Object
- #date_time ⇒ Object
- #exif ⇒ Object
-
#initialize(name, base) ⇒ GalleryImage
constructor
A new instance of GalleryImage.
- #to_liquid ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, base) ⇒ GalleryImage
Returns a new instance of GalleryImage.
16 17 18 19 |
# File 'lib/jekyll-gallery-generator.rb', line 16 def initialize(name, base) @name = name @path = File.join(base, name) end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
13 14 15 |
# File 'lib/jekyll-gallery-generator.rb', line 13 def name @name end |
#path ⇒ Object
Returns the value of attribute path.
14 15 16 |
# File 'lib/jekyll-gallery-generator.rb', line 14 def path @path end |
Instance Method Details
#<=>(b) ⇒ Object
21 22 23 24 |
# 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 ⇒ Object
26 27 28 29 30 31 32 33 34 |
# 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 ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# 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 ⇒ Object
53 54 55 56 57 58 59 60 61 |
# 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 ⇒ Object
49 50 51 |
# File 'lib/jekyll-gallery-generator.rb', line 49 def to_s return @name end |