Class: Octopussy::Repo
- Inherits:
-
Object
- Object
- Octopussy::Repo
- Defined in:
- lib/octopussy/repo.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(repo) ⇒ Repo
constructor
A new instance of Repo.
- #repo ⇒ Object
- #slug ⇒ Object
- #to_s ⇒ Object
- #url ⇒ Object
- #user ⇒ Object
- #user=(val) ⇒ Object
Constructor Details
#initialize(repo) ⇒ Repo
Returns a new instance of Repo.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/octopussy/repo.rb', line 5 def initialize(repo) if repo.is_a?(String) repo = repo.split("/") @name = repo.pop @username = repo.pop elsif repo.is_a?(Repo) @username = repo.username @name = repo.name elsif repo.is_a?(Hash) @name = repo[:repo] ||= repo[:name] @username = repo[:username] ||= repo[:user] ||= repo[:owner] end end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/octopussy/repo.rb', line 3 def name @name end |
#username ⇒ Object
Returns the value of attribute username.
3 4 5 |
# File 'lib/octopussy/repo.rb', line 3 def username @username end |
Class Method Details
Instance Method Details
#repo ⇒ Object
35 36 37 |
# File 'lib/octopussy/repo.rb', line 35 def repo @name end |
#slug ⇒ Object
19 20 21 |
# File 'lib/octopussy/repo.rb', line 19 def slug "#{@username}/#{@name}" end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/octopussy/repo.rb', line 23 def to_s self.slug end |
#url ⇒ Object
27 28 29 |
# File 'lib/octopussy/repo.rb', line 27 def url "http://github.com/#{slug}" end |
#user ⇒ Object
31 32 33 |
# File 'lib/octopussy/repo.rb', line 31 def user @username end |
#user=(val) ⇒ Object
39 40 41 |
# File 'lib/octopussy/repo.rb', line 39 def user=(val) @username = val end |