Class: Ukiryu::Extractors::BaseExtractor Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/ukiryu/extractors/base_extractor.rb

Overview

This class is abstract.

Subclasses must implement the ‘extract` method

Base class for definition extraction strategies

Each extraction strategy implements a different approach to extracting tool definitions from CLI tools.

Direct Known Subclasses

HelpParser, NativeExtractor

Instance Method Summary collapse

Constructor Details

#initialize(tool_name, options = {}) ⇒ BaseExtractor

Initialize the extractor

Parameters:

  • tool_name (String, Symbol)

    the tool name

  • options (Hash) (defaults to: {})

    extraction options



16
17
18
19
# File 'lib/ukiryu/extractors/base_extractor.rb', line 16

def initialize(tool_name, options = {})
  @tool_name = tool_name
  @options = options
end

Instance Method Details

#available?Boolean

Check if this extractor can extract from the tool

Returns:

  • (Boolean)

    true if extraction is possible

Raises:

  • (NotImplementedError)


34
35
36
# File 'lib/ukiryu/extractors/base_extractor.rb', line 34

def available?
  raise NotImplementedError, "#{self.class} must implement #available?"
end

#extractString?

Extract definition from the tool

Subclasses must implement this method

Returns:

  • (String, nil)

    the YAML definition or nil if extraction failed

Raises:

  • (NotImplementedError)

    if not implemented in subclass



27
28
29
# File 'lib/ukiryu/extractors/base_extractor.rb', line 27

def extract
  raise NotImplementedError, "#{self.class} must implement #extract"
end