Class: Octokit::Repository
- Inherits:
-
Object
- Object
- Octokit::Repository
- Defined in:
- lib/octokit/repository.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
(also: #repo)
Returns the value of attribute name.
-
#username ⇒ Object
(also: #user)
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(repo) ⇒ Repository
constructor
A new instance of Repository.
- #slug ⇒ Object
- #to_s ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(repo) ⇒ Repository
Returns a new instance of Repository.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/octokit/repository.rb', line 11 def initialize(repo) case repo when String @username, @name = repo.split('/') when Repository @username = repo.username @name = repo.name when Hash @name = repo[:repo] ||= repo[:name] @username = repo[:username] ||= repo[:user] ||= repo[:owner] end end |
Instance Attribute Details
#name ⇒ Object Also known as: repo
Returns the value of attribute name.
5 6 7 |
# File 'lib/octokit/repository.rb', line 5 def name @name end |
#username ⇒ Object Also known as: user
Returns the value of attribute username.
5 6 7 |
# File 'lib/octokit/repository.rb', line 5 def username @username end |
Class Method Details
.from_url(url) ⇒ Object
7 8 9 |
# File 'lib/octokit/repository.rb', line 7 def self.from_url(url) Repository.new(Addressable::URI.parse(url).path[1..-1]) end |
Instance Method Details
#slug ⇒ Object
24 25 26 |
# File 'lib/octokit/repository.rb', line 24 def slug [@username, @name].compact.join('/') end |
#to_s ⇒ Object
28 29 30 |
# File 'lib/octokit/repository.rb', line 28 def to_s self.slug end |
#url ⇒ Object
32 33 34 |
# File 'lib/octokit/repository.rb', line 32 def url "https://github.com/#{slug}" end |