Class: CLI::Mastermind::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/cli/mastermind/loader.rb,
lib/cli/mastermind/loader/planfile_loader.rb

Direct Known Subclasses

PlanfileLoader

Defined Under Namespace

Classes: PlanfileLoader

Constant Summary collapse

@@loaders =
[]

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.loadable_extensionsObject (readonly)

Returns the value of attribute loadable_extensions.



4
5
6
# File 'lib/cli/mastermind/loader.rb', line 4

def loadable_extensions
  @loadable_extensions
end

Class Method Details

.can_load?(extension) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/cli/mastermind/loader.rb', line 23

def can_load?(extension)
  @loadable_extensions.include? extension
end

.find_loader(extension) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/cli/mastermind/loader.rb', line 11

def find_loader(extension)
  loader = @@loaders.find { |l| l.can_load? extension }

  raise UnsupportedFileTypeError.new(extension) unless loader

  loader
end

.inherited(subclass) ⇒ Object



7
8
9
# File 'lib/cli/mastermind/loader.rb', line 7

def inherited(subclass)
  @@loaders << subclass
end

.load(filename) ⇒ Object

Raises:

  • (NotImplementedError)


27
28
29
# File 'lib/cli/mastermind/loader.rb', line 27

def load(filename)
  raise NotImplementedError
end

.supported_extensionsObject



19
20
21
# File 'lib/cli/mastermind/loader.rb', line 19

def supported_extensions
  @@loaders.flat_map { |l| l.loadable_extensions }
end