Class: KrakendOpenAPI::FileReader

Inherits:
Object
  • Object
show all
Defined in:
lib/readers/file_reader.rb

Overview

Reads absolute/relative files

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ FileReader

Returns a new instance of FileReader.



6
7
8
# File 'lib/readers/file_reader.rb', line 6

def initialize(file_path)
  @file_path = file_path
end

Instance Method Details

#readObject



10
11
12
13
14
15
16
17
# File 'lib/readers/file_reader.rb', line 10

def read
  pwd = File.expand_path(Dir.pwd)
  if Pathname.new(@file_path).absolute?
    File.read(@file_path)
  else
    File.read(File.expand_path(@file_path, pwd))
  end
end