Class: Toys::SourceSpec::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/toys/source_spec.rb

Overview

The base class of a source spec, holding the attributes common to every kind, and implementing equality.

Do not instantiate this class directly. Use one of the factory methods such as path.

Direct Known Subclasses

Block, Gem, Git, Path

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#context_directoryString? (readonly)

The context directory for tools loaded from this source, or nil if the source does not dictate a context directory.

Returns:

  • (String, nil)


208
209
210
# File 'lib/toys/source_spec.rb', line 208

def context_directory
  @context_directory
end

#source_nameString? (readonly)

The user-visible name for tools loaded from this source, or nil to generate a default at resolution time.

Returns:

  • (String, nil)


216
217
218
# File 'lib/toys/source_spec.rb', line 216

def source_name
  @source_name
end

Instance Method Details

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

Source specs compare by value. Specs of different kinds are never equal, even if their common attributes match.

Parameters:

  • other (Object)

Returns:

  • (boolean)


225
226
227
# File 'lib/toys/source_spec.rb', line 225

def ==(other)
  other.class.equal?(self.class) && other.equality_fields == equality_fields
end

#hashInteger

Returns:

  • (Integer)


233
234
235
# File 'lib/toys/source_spec.rb', line 233

def hash
  equality_fields.hash
end