class CabezaDeTermo::AssetsPublisher::Asset
An assets to be included in a template.
Public Class Methods
new(asset_type, asset_uri, location)
click to toggle source
Initialize the instance.
# File lib/cabeza-de-termo/assets-publisher/assets/asset.rb, line 16 def initialize(asset_type, asset_uri, location) @uri = Pathname.new(asset_uri) @type = asset_type @location = location @real_path = nil @uri_parameters = nil end
on_uri(asset_type, asset_uri)
click to toggle source
Answer a new asset on the asset_uri.
# File lib/cabeza-de-termo/assets-publisher/assets/asset.rb, line 11 def self.on_uri(asset_type, asset_uri) new(asset_type, asset_uri, Location.from(asset_uri)) end
Public Instance Methods
html()
click to toggle source
Answer the html to include this asset in a template
# File lib/cabeza-de-termo/assets-publisher/assets/asset.rb, line 61 def html() type.html_for uri_with_parameters end
location()
click to toggle source
Answer the location of the asset
# File lib/cabeza-de-termo/assets-publisher/assets/asset.rb, line 42 def location() @location end
modification_time()
click to toggle source
# File lib/cabeza-de-termo/assets-publisher/assets/asset.rb, line 69 def modification_time() return :not_found unless real_path.exist? real_path.mtime end
real_path()
click to toggle source
Answer the file path of the asset uri.
# File lib/cabeza-de-termo/assets-publisher/assets/asset.rb, line 47 def real_path() @real_path ||= location.real_path_of(uri) end
set_uri_parameters(string)
click to toggle source
# File lib/cabeza-de-termo/assets-publisher/assets/asset.rb, line 55 def set_uri_parameters(string) @uri_parameters = string self end
type()
click to toggle source
Answer the asset type
# File lib/cabeza-de-termo/assets-publisher/assets/asset.rb, line 37 def type() @type end
uri()
click to toggle source
Answer the asset uri.
# File lib/cabeza-de-termo/assets-publisher/assets/asset.rb, line 25 def uri() @uri end
uri_parameters()
click to toggle source
# File lib/cabeza-de-termo/assets-publisher/assets/asset.rb, line 51 def uri_parameters() @uri_parameters end
uri_with_parameters()
click to toggle source
Answer the asset uri with optional parameters
# File lib/cabeza-de-termo/assets-publisher/assets/asset.rb, line 30 def uri_with_parameters() return uri.to_s if uri_parameters.nil? uri.to_s + '?' + URI.escape(uri_parameters) end
validate_real_path()
click to toggle source
# File lib/cabeza-de-termo/assets-publisher/assets/asset.rb, line 65 def validate_real_path() raise_asset_not_found_error unless real_path.exist? end
Protected Instance Methods
raise_asset_not_found_error()
click to toggle source
# File lib/cabeza-de-termo/assets-publisher/assets/asset.rb, line 76 def raise_asset_not_found_error() raise AssetNotFoundError.new(uri) end