Class: Jekyll::Assets::Drop

Inherits:
Liquid::Drop
  • Object
show all
Extended by:
Forwardable::Extended
Defined in:
lib/jekyll/assets/drop.rb

Instance Method Summary collapse

Constructor Details

#initialize(path, jekyll:) ⇒ Drop

Returns a new instance of Drop.



13
14
15
16
17
18
# File 'lib/jekyll/assets/drop.rb', line 13

def initialize(path, jekyll:)
  @path = path.to_s
  @sprockets = jekyll.sprockets
  @jekyll = jekyll
  @asset = nil
end

Instance Method Details

#digest_pathString

TODO:

this needs to move to ‘_url`

– The digest path. –

Returns:

  • (String)

    the prefixed and digested path.



32
33
34
# File 'lib/jekyll/assets/drop.rb', line 32

def digest_path
  @sprockets.prefix_url(asset.digest_path)
end

#dimensionsHash<Integer,Integer>

Note:

this can break easily.

– Image dimensions if the asest is an image. –

Returns:

  • (Hash<Integer,Integer>)

    the dimensions.



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/jekyll/assets/drop.rb', line 41

def dimensions
  @dimensions ||= begin
    img = FastImage.size(asset.filename.to_s)

    {
      "width"  => img[0],
      "height" => img[1],
    }
  rescue => e
    Logger.error e
  end
end