Class: GithubUrl
- Inherits:
-
Object
- Object
- GithubUrl
- Defined in:
- lib/github_url.rb,
lib/github_url/version.rb
Defined Under Namespace
Classes: Invalid
Constant Summary collapse
- GITHUB_HOST =
"github.com"- VERSION =
"0.1.0"
Instance Attribute Summary collapse
-
#default_branch ⇒ Object
Returns the value of attribute default_branch.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #branch ⇒ Object
-
#initialize(url, default_branch = "master") ⇒ GithubUrl
constructor
A new instance of GithubUrl.
- #organization ⇒ Object
- #path ⇒ Object
- #repository ⇒ Object
Constructor Details
#initialize(url, default_branch = "master") ⇒ GithubUrl
Returns a new instance of GithubUrl.
9 10 11 12 13 14 |
# File 'lib/github_url.rb', line 9 def initialize(url, default_branch = "master") @default_branch = default_branch @url = url validate_url end |
Instance Attribute Details
#default_branch ⇒ Object
Returns the value of attribute default_branch.
2 3 4 |
# File 'lib/github_url.rb', line 2 def default_branch @default_branch end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/github_url.rb', line 2 def url @url end |
Instance Method Details
#branch ⇒ Object
24 25 26 |
# File 'lib/github_url.rb', line 24 def branch default_branch? ? @default_branch : url_path[3] end |
#organization ⇒ Object
16 17 18 |
# File 'lib/github_url.rb', line 16 def organization url_path[0] end |
#path ⇒ Object
28 29 30 |
# File 'lib/github_url.rb', line 28 def path default_branch? ? File.join(url_path[2..-1]) : File.join(url_path[4..-1].to_a) end |
#repository ⇒ Object
20 21 22 |
# File 'lib/github_url.rb', line 20 def repository url_path[1] end |