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)


194
195
196
# File 'lib/toys/source_spec.rb', line 194

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)


202
203
204
# File 'lib/toys/source_spec.rb', line 202

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)


211
212
213
# File 'lib/toys/source_spec.rb', line 211

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

#hashInteger

Returns:

  • (Integer)


219
220
221
# File 'lib/toys/source_spec.rb', line 219

def hash
  equality_fields.hash
end