Class: TrackR::Tracker
- Inherits:
-
Object
- Object
- TrackR::Tracker
- Defined in:
- lib/track-r/tracker.rb
Overview
The class is a wrapper for getting projects, stories and using tokens. It’s main purpose is relating the three allowing to interact with a project, and its stories using a token. Expects a token when initialized.
Instance Method Summary collapse
-
#find_project ⇒ Object
Receives a block with the condition to find a project.
-
#initialize(token) ⇒ Tracker
constructor
To generate a token, use the “Create New TrackR::Token” link on the My Profile page (www.pivotaltracker.com/profile).
-
#project(project_id) ⇒ Object
Fetches project with given ID Returns a TrackR::Project object.
-
#projects ⇒ Object
Alias for get_projects Returns an array of projects.
-
#sync ⇒ Object
Refresh the projects from the server Returns an array of projects.
Constructor Details
#initialize(token) ⇒ Tracker
To generate a token, use the “Create New TrackR::Token” link on the My Profile page (www.pivotaltracker.com/profile).
10 11 12 13 |
# File 'lib/track-r/tracker.rb', line 10 def initialize(token) @token = token raise TypeError unless @token.is_a? TrackR::Token end |
Instance Method Details
#find_project ⇒ Object
Receives a block with the condition to find a project. Should work the same as Enumerable.find method Returns a TrackR::Project object
35 36 37 38 39 40 |
# File 'lib/track-r/tracker.rb', line 35 def find_project get_projects unless defined?(@projects) && @projects.is_a?(Array) @projects.find do |project| yield(project) end end |
#project(project_id) ⇒ Object
Fetches project with given ID Returns a TrackR::Project object
17 18 19 |
# File 'lib/track-r/tracker.rb', line 17 def project(project_id) @project = TrackR::Project.new(:project_id => project_id , :token => @token) end |
#projects ⇒ Object
Alias for get_projects Returns an array of projects
30 |
# File 'lib/track-r/tracker.rb', line 30 def projects ; get_projects ; end |
#sync ⇒ Object
Refresh the projects from the server Returns an array of projects
23 24 25 26 |
# File 'lib/track-r/tracker.rb', line 23 def sync @projects = nil get_projects end |