Class: Jekyll::AssetsPlugin::AssetPath

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll/assets_plugin/asset_path.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(asset) ⇒ AssetPath

Returns a new instance of AssetPath.



6
7
8
9
# File 'lib/jekyll/assets_plugin/asset_path.rb', line 6

def initialize(asset)
  asset.bundle!
  @asset = asset
end

Instance Attribute Details

#anchorObject



30
31
32
# File 'lib/jekyll/assets_plugin/asset_path.rb', line 30

def anchor
  "##{@anchor}" if @anchor
end

#queryObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/jekyll/assets_plugin/asset_path.rb', line 19

def query
  query = []

  query << "cb=#{@asset.digest}" if :soft == cachebust
  query << @query                if @query

  return if query.empty?

  "?" << query.join("&")
end

Instance Method Details

#cachebustObject



11
12
13
# File 'lib/jekyll/assets_plugin/asset_path.rb', line 11

def cachebust
  @cachebust ||= @asset.site.assets_config.cachebust
end

#pathObject



15
16
17
# File 'lib/jekyll/assets_plugin/asset_path.rb', line 15

def path
  :hard == cachebust && @asset.digest_path || @asset.logical_path
end

#to_sObject



34
35
36
# File 'lib/jekyll/assets_plugin/asset_path.rb', line 34

def to_s
  "#{@asset.site.assets_config.baseurl}/#{path}#{query}#{anchor}"
end