Class: RgGen::InputBase::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/rggen/input_base/loader.rb

Direct Known Subclasses

RegisterMap::Loader

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.supported_types=(value) ⇒ Object (writeonly)

Sets the attribute supported_types

Parameters:

  • value

    the value to set the attribute supported_types to.



5
6
7
# File 'lib/rggen/input_base/loader.rb', line 5

def supported_types=(value)
  @supported_types = value
end

Class Method Details

.acceptable?(file) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
10
# File 'lib/rggen/input_base/loader.rb', line 7

def acceptable?(file)
  ext = File.ext(file).to_sym
  @supported_types.any? { |type| type.casecmp(ext).zero? }
end

.load(file) ⇒ Object



12
13
14
# File 'lib/rggen/input_base/loader.rb', line 12

def load(file)
  new.load(file)
end

Instance Method Details

#load(file) ⇒ Object

Raises:



17
18
19
20
# File 'lib/rggen/input_base/loader.rb', line 17

def load(file)
  return load_file(file) if File.exist?(file)
  raise RgGen::LoadError, "cannot load such file -- #{file}"
end