Class: Opal::PathReader
- Inherits:
-
Object
- Object
- Opal::PathReader
- Defined in:
- opal/lib/opal/path_reader.rb
Instance Method Summary collapse
- #append_paths(*paths) ⇒ Object
- #expand(path) ⇒ Object
-
#initialize(file_finder = HikePathFinder.new) ⇒ PathReader
constructor
A new instance of PathReader.
- #paths ⇒ Object
- #read(path) ⇒ Object
Constructor Details
#initialize(file_finder = HikePathFinder.new) ⇒ PathReader
Returns a new instance of PathReader
5 6 7 |
# File 'opal/lib/opal/path_reader.rb', line 5 def initialize(file_finder = HikePathFinder.new) @file_finder = file_finder end |
Instance Method Details
#append_paths(*paths) ⇒ Object
27 28 29 |
# File 'opal/lib/opal/path_reader.rb', line 27 def append_paths(*paths) file_finder.append_paths(*paths) end |
#expand(path) ⇒ Object
15 16 17 18 19 20 21 |
# File 'opal/lib/opal/path_reader.rb', line 15 def (path) if Pathname.new(path).absolute? || path =~ %r{\A\.?\.#{File::SEPARATOR}} path else file_finder.find(path) end end |
#paths ⇒ Object
23 24 25 |
# File 'opal/lib/opal/path_reader.rb', line 23 def paths file_finder.paths end |
#read(path) ⇒ Object
9 10 11 12 13 |
# File 'opal/lib/opal/path_reader.rb', line 9 def read(path) full_path = (path) return nil if full_path.nil? File.open(full_path, 'rb:UTF-8'){|f| f.read} end |