Sha256: 1f3c822d6693979217fa7c8e1f79c6460cf4a2bdf7d01c27c4ceab15edf0f170

Contents?: true

Size: 877 Bytes

Versions: 3

Compression:

Stored size: 877 Bytes

Contents

require 'pathname'

require 'skippy/library'

class Skippy::LibModule

  attr_reader :path, :library

  class ModuleNotFoundError < Skippy::Error; end

  # @param [Skippy::Library] library
  # @param [String] path
  def initialize(library, path)
    @path = Pathname.new(path)
    raise ModuleNotFoundError, @path.to_s unless @path.file?
    @library = library
  end

  def <=>(other)
    other.is_a?(self.class) ? name <=> other.name : nil
  end

  def eql?(other)
    # http://javieracero.com/blog/the-key-to-ruby-hashes-is-eql-hash
    other.is_a?(self.class) && name.casecmp(other.name).zero?
  end

  # @param [String]
  def basename
    path.basename('.*').to_s
  end

  def hash
    name.hash
  end

  # @param [String]
  def name
    "#{library.name}/#{basename}"
  end

  # @param [String]
  def to_s
    name
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
skippy-0.4.1.a lib/skippy/lib_module.rb
skippy-0.4.0.a lib/skippy/lib_module.rb
skippy-0.3.0.a lib/skippy/lib_module.rb