Class: Bettery::Project
- Inherits:
-
Object
- Object
- Bettery::Project
- Defined in:
- lib/bettery/project.rb
Constant Summary collapse
- REGEXP =
/\Ahttps?.+\/projects\/(?<id>\d+).*\z/
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
Class Method Summary collapse
-
.path(project) ⇒ String
Get the api path for a project.
Instance Method Summary collapse
-
#initialize(project) ⇒ Project
constructor
A new instance of Project.
-
#path ⇒ String
Project API path.
-
#url ⇒ String
Project URL based on Client#api_endpoint.
Constructor Details
#initialize(project) ⇒ Project
Returns a new instance of Project.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/bettery/project.rb', line 6 def initialize(project) case project when Integer @id = project when String @id = extract_id_from_url(project) when Project @id = project.id when Hash @id = project[:id] end end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/bettery/project.rb', line 3 def id @id end |
Class Method Details
.path(project) ⇒ String
Get the api path for a project
27 28 29 |
# File 'lib/bettery/project.rb', line 27 def self.path project new(project).path end |
Instance Method Details
#path ⇒ String
Returns Project API path.
20 21 22 |
# File 'lib/bettery/project.rb', line 20 def path "projects/#{id}.json" end |
#url ⇒ String
Project URL based on Client#api_endpoint
33 34 35 |
# File 'lib/bettery/project.rb', line 33 def url File.join(Bettery.api_endpoint, path) end |