Class: Bookwatch::Ingest::RepoIdentifier

Inherits:
Object
  • Object
show all
Defined in:
lib/bookwatch/ingest/repo_identifier.rb

Constant Summary collapse

DEFAULT_VCS_PREFIX =
'[email protected]:'

Instance Method Summary collapse

Constructor Details

#initialize(input_identifier) ⇒ RepoIdentifier

Returns a new instance of RepoIdentifier.



6
7
8
# File 'lib/bookwatch/ingest/repo_identifier.rb', line 6

def initialize(input_identifier)
  @input_identifier = input_identifier
end

Instance Method Details

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



34
35
36
# File 'lib/bookwatch/ingest/repo_identifier.rb', line 34

def ==(other)
  to_str == other
end

#hashObject



30
31
32
# File 'lib/bookwatch/ingest/repo_identifier.rb', line 30

def hash
  to_str.hash
end

#inspectObject



22
23
24
# File 'lib/bookwatch/ingest/repo_identifier.rb', line 22

def inspect
  %Q("#{to_s}")
end

#split(*args) ⇒ Object



26
27
28
# File 'lib/bookwatch/ingest/repo_identifier.rb', line 26

def split(*args)
  input_identifier.split(*args)
end

#to_strObject Also known as: to_s



10
11
12
13
14
15
16
17
18
# File 'lib/bookwatch/ingest/repo_identifier.rb', line 10

def to_str
  if input_identifier.nil?
    ""
  elsif input_identifier.include?(':') || input_identifier.match(/^\//)
    input_identifier
  else
    "#{DEFAULT_VCS_PREFIX}#{input_identifier}"
  end
end