Module: Prmd::MultiLoader::Loader

Included in:
Json, Toml, Yajl, Yaml
Defined in:
lib/prmd/multi_loader/loader.rb

Overview

Base Loader module used to extend all other loaders

Instance Method Summary collapse

Instance Method Details

#load_data(data) ⇒ Object

This method is abstract.

Using the loader, parse or do whatever magic the loader does to the string to get back data.

Parameters:

  • data (String)

Returns:

  • (Object)


90
91
92
# File 'lib/prmd/multi_loader/loader.rb', line 90

def load_data(data)
  # overwrite in children
end

#load_file(filename) ⇒ Object

Load a file given a filename

Parameters:

  • filename (String)

Returns:

  • (Object)


111
112
113
# File 'lib/prmd/multi_loader/loader.rb', line 111

def load_file(filename)
  File.open(filename, 'r') { |f| return load_stream(f) }
end

#load_stream(stream) ⇒ Object

Load a stream

Parameters:

  • stream (IO)

Returns:

  • (Object)


101
102
103
# File 'lib/prmd/multi_loader/loader.rb', line 101

def load_stream(stream)
  load_data(stream.read)
end