Class: Prawn::SVG::Loaders::File
- Inherits:
-
Object
- Object
- Prawn::SVG::Loaders::File
- Defined in:
- lib/prawn/svg/loaders/file.rb
Instance Attribute Summary collapse
-
#root_path ⇒ Object
readonly
Returns the value of attribute root_path.
Instance Method Summary collapse
- #from_url(url) ⇒ Object
-
#initialize(root_path) ⇒ File
constructor
A new instance of File.
Constructor Details
#initialize(root_path) ⇒ File
Returns a new instance of File.
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/prawn/svg/loaders/file.rb', line 35 def initialize(root_path) if root_path.empty? raise ArgumentError, "An empty string is not a valid root path. Use '.' if you want the current working directory." end @root_path = ::File.(root_path) raise ArgumentError, "#{root_path} is not a directory" unless Dir.exist?(@root_path) end |
Instance Attribute Details
#root_path ⇒ Object (readonly)
Returns the value of attribute root_path.
33 34 35 |
# File 'lib/prawn/svg/loaders/file.rb', line 33 def root_path @root_path end |
Instance Method Details
#from_url(url) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/prawn/svg/loaders/file.rb', line 46 def from_url(url) uri = build_uri(url) if uri && uri.scheme.nil? && uri.path load_file(uri.path) elsif uri && uri.scheme == 'file' assert_valid_file_uri!(uri) path = windows? ? fix_windows_path(uri.path) : uri.path load_file(path) end end |