class Swarker::Readers::FileReader
Constants
- ERB_EXT
- JSON_EXT
- YAML_EXT
Attributes
path[R]
Public Class Methods
new(path)
click to toggle source
# File lib/swarker/readers/file_reader.rb, line 14 def initialize(path) @path = path end
Public Instance Methods
read()
click to toggle source
# File lib/swarker/readers/file_reader.rb, line 18 def read HashWithIndifferentAccess.new(readed_hash) end
Private Instance Methods
read_erb()
click to toggle source
# File lib/swarker/readers/file_reader.rb, line 43 def read_erb YAML.load(ERB.new(File.read(path)).result) end
read_json()
click to toggle source
# File lib/swarker/readers/file_reader.rb, line 35 def read_json JSON.parse(File.read(path)) end
read_yaml()
click to toggle source
# File lib/swarker/readers/file_reader.rb, line 39 def read_yaml YAML.load_file(path) end
readed_hash()
click to toggle source
# File lib/swarker/readers/file_reader.rb, line 24 def readed_hash case File.extname(path) when JSON_EXT read_json when YAML_EXT read_yaml when ERB_EXT read_erb end end