Class: Metanorma::Release::RepoRef

Inherits:
Object
  • Object
show all
Defined in:
lib/metanorma/release/repo_ref.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(owner:, repo:) ⇒ RepoRef

Returns a new instance of RepoRef.



15
16
17
18
19
# File 'lib/metanorma/release/repo_ref.rb', line 15

def initialize(owner:, repo:)
  @owner = owner
  @repo = repo
  freeze
end

Instance Attribute Details

#ownerObject (readonly)

Returns the value of attribute owner.



6
7
8
# File 'lib/metanorma/release/repo_ref.rb', line 6

def owner
  @owner
end

#repoObject (readonly)

Returns the value of attribute repo.



6
7
8
# File 'lib/metanorma/release/repo_ref.rb', line 6

def repo
  @repo
end

Class Method Details

.from_string(str) ⇒ Object

Raises:

  • (ArgumentError)


8
9
10
11
12
13
# File 'lib/metanorma/release/repo_ref.rb', line 8

def self.from_string(str)
  parts = str.split('/', 2)
  raise ArgumentError, "Invalid repo reference: #{str}" unless parts.length == 2

  new(owner: parts[0], repo: parts[1])
end

Instance Method Details

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/metanorma/release/repo_ref.rb', line 25

def eql?(other)
  other.is_a?(self.class) && owner == other.owner && repo == other.repo
end

#hashObject



29
30
31
# File 'lib/metanorma/release/repo_ref.rb', line 29

def hash
  [owner, repo].hash
end

#to_sObject



21
22
23
# File 'lib/metanorma/release/repo_ref.rb', line 21

def to_s
  "#{owner}/#{repo}"
end