Module: Saxon::Source::Helpers
- Defined in:
- lib/saxon/source.rb
Class Method Summary collapse
-
.base_uri(io) ⇒ String?
Given a File, or IO object which will return either #path or #base_uri, return the #base_uri, if present, or the #path, if present, or nil.
-
.file(path) ⇒ java.io.File
Given a path return a Java File object.
-
.inputstream(io) ⇒ java.io.InputStream
Given a File or IO return a Java InputStream.
Class Method Details
.base_uri(io) ⇒ String?
Given a File, or IO object which will return either #path or #base_uri, return the #base_uri, if present, or the #path, if present, or nil
19 20 21 22 23 24 |
# File 'lib/saxon/source.rb', line 19 def self.base_uri(io) if io.respond_to?(:base_uri) return io.base_uri.to_s end io.path if io.respond_to?(:path) end |
.file(path) ⇒ java.io.File
Given a path return a Java File object
42 43 44 |
# File 'lib/saxon/source.rb', line 42 def self.file(path) java.io.File.new(path.to_s) end |
.inputstream(io) ⇒ java.io.InputStream
Given a File or IO return a Java InputStream
30 31 32 33 34 35 36 37 |
# File 'lib/saxon/source.rb', line 30 def self.inputstream(io) case io when org.jruby.util.IOInputStream, java.io.InputStream io else io.to_inputstream if io.respond_to?(:read) end end |