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".freeze
- VERSION =
"0.2.0"
Instance Attribute Summary collapse
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #branch ⇒ Object
-
#initialize(url:, default_branch: "master", host: GITHUB_HOST) ⇒ GithubUrl
constructor
A new instance of GithubUrl.
- #organization ⇒ Object
- #path ⇒ Object
- #repository ⇒ Object
Constructor Details
#initialize(url:, default_branch: "master", host: GITHUB_HOST) ⇒ GithubUrl
Returns a new instance of GithubUrl.
9 10 11 12 13 14 15 |
# File 'lib/github_url.rb', line 9 def initialize(url:, default_branch: "master", host: GITHUB_HOST) @default_branch = default_branch @url = url @host = host validate_url end |
Instance Attribute Details
#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
25 26 27 |
# File 'lib/github_url.rb', line 25 def branch default_branch? ? @default_branch : url_path[3] end |
#organization ⇒ Object
17 18 19 |
# File 'lib/github_url.rb', line 17 def organization url_path[0] end |
#path ⇒ Object
29 30 31 |
# File 'lib/github_url.rb', line 29 def path default_branch? ? File.join(url_path[2..-1]) : File.join(url_path[4..-1].to_a) end |
#repository ⇒ Object
21 22 23 |
# File 'lib/github_url.rb', line 21 def repository url_path[1] end |