Class: Prawn::SVG::UrlLoader
- Inherits:
-
Object
- Object
- Prawn::SVG::UrlLoader
- Defined in:
- lib/prawn/svg/url_loader.rb
Constant Summary collapse
- Error =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#enable_cache ⇒ Object
readonly
Returns the value of attribute enable_cache.
-
#loaders ⇒ Object
readonly
Returns the value of attribute loaders.
Instance Method Summary collapse
- #add_to_cache(url, data) ⇒ Object
-
#initialize(enable_cache: false, enable_web: true, enable_file_with_root: nil) ⇒ UrlLoader
constructor
A new instance of UrlLoader.
- #load(url) ⇒ Object
- #retrieve_from_cache(url) ⇒ Object
Constructor Details
#initialize(enable_cache: false, enable_web: true, enable_file_with_root: nil) ⇒ UrlLoader
Returns a new instance of UrlLoader.
6 7 8 9 10 11 12 13 14 |
# File 'lib/prawn/svg/url_loader.rb', line 6 def initialize(enable_cache: false, enable_web: true, enable_file_with_root: nil) @url_cache = {} @enable_cache = enable_cache @loaders = [] loaders << Prawn::SVG::Loaders::Data.new loaders << Prawn::SVG::Loaders::Web.new if enable_web loaders << Prawn::SVG::Loaders::File.new(enable_file_with_root) if enable_file_with_root end |
Instance Attribute Details
#enable_cache ⇒ Object (readonly)
Returns the value of attribute enable_cache.
4 5 6 |
# File 'lib/prawn/svg/url_loader.rb', line 4 def enable_cache @enable_cache end |
#loaders ⇒ Object (readonly)
Returns the value of attribute loaders.
4 5 6 |
# File 'lib/prawn/svg/url_loader.rb', line 4 def loaders @loaders end |
Instance Method Details
#add_to_cache(url, data) ⇒ Object
20 21 22 |
# File 'lib/prawn/svg/url_loader.rb', line 20 def add_to_cache(url, data) @url_cache[url] = data end |
#load(url) ⇒ Object
16 17 18 |
# File 'lib/prawn/svg/url_loader.rb', line 16 def load(url) retrieve_from_cache(url) || perform_and_cache(url) end |
#retrieve_from_cache(url) ⇒ Object
24 25 26 |
# File 'lib/prawn/svg/url_loader.rb', line 24 def retrieve_from_cache(url) @url_cache[url] end |