Class: Ukiryu::Definition::Source Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/ukiryu/definition/source.rb

Overview

This class is abstract.

Subclasses must implement #load, #cache_key, and #source_type

Abstract base class for definition sources

A source represents a location from which a tool definition can be loaded. Each source type (file, string, bundled, register) implements this interface.

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Boolean Also known as: eql?

Check if this source is equal to another

Two sources are equal if they have the same cache key.

Parameters:

  • other (Object)

    the object to compare

Returns:

  • (Boolean)

    true if sources are equal



47
48
49
50
51
# File 'lib/ukiryu/definition/source.rb', line 47

def ==(other)
  return false unless other.is_a?(Source)

  cache_key == other.cache_key
end

#cache_keyString

This method is abstract.

Get a unique cache key for this source

The cache key must uniquely identify both the source location and its content to ensure proper cache invalidation.

Returns:

  • (String)

    a unique cache key

Raises:

  • (NotImplementedError)


29
30
31
# File 'lib/ukiryu/definition/source.rb', line 29

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

#hashInteger

Generate hash code for hash storage

Returns:

  • (Integer)

    hash code based on cache key



57
58
59
# File 'lib/ukiryu/definition/source.rb', line 57

def hash
  cache_key.hash
end

#inspectString

Inspect representation

Returns:

  • (String)

    detailed inspection string



71
72
73
# File 'lib/ukiryu/definition/source.rb', line 71

def inspect
  "#<#{self.class.name} source_type=#{source_type} cache_key=#{cache_key}>"
end

#loadString

This method is abstract.

Load the YAML definition content

Returns:

  • (String)

    the YAML content

Raises:

  • (DefinitionLoadError)

    if the definition cannot be loaded



18
19
20
# File 'lib/ukiryu/definition/source.rb', line 18

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

#source_typeSymbol

This method is abstract.

Get the source type identifier

Returns:

  • (Symbol)

    the source type (:file, :string, :bundled, :register)

Raises:

  • (NotImplementedError)


37
38
39
# File 'lib/ukiryu/definition/source.rb', line 37

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

#to_sString

String representation

Returns:

  • (String)

    source description



64
65
66
# File 'lib/ukiryu/definition/source.rb', line 64

def to_s
  "#{source_type}:#{cache_key}"
end