Class: Iteration

Inherits:
Object
  • Object
show all
Defined in:
lib/track-r/iteration.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Iteration

Returns a new instance of Iteration.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/track-r/iteration.rb', line 15

def initialize(options={})
  @token = options[:token] || Token.new
  if options.include?(:project_id) && options.include?(:iteration_id)
    @id         = options[:iteration_id]
    @project_id = options[:project_id]
    @number     = options[:number]
    @type       = assign_type(options[:type])
    @limit      = options[:limit]
    @offset     = options[:offset]
    @api_url    = build_api_url
    @iteration  = Hpricot(open(@api_url, {"X-TrackerToken" => @token}))
  elsif options.include?(:iteration) && options.include?(:project_id)
    @project_id = options[:project_id]
    @iteration  = options[:iteration]
  else
    raise ArgumentError, "Valid options are: :iteration (receives an Hpricot Object) + :project_id OR :project_id + :iteration_id"
  end
  build_iteration
end

Instance Attribute Details

#finish_date(format = "%m/%d/%Y") ⇒ Object (readonly)

Returns the value of attribute finish_date.



2
3
4
# File 'lib/track-r/iteration.rb', line 2

def finish_date
  @finish_date
end

#idObject (readonly)

Returns the value of attribute id.



2
3
4
# File 'lib/track-r/iteration.rb', line 2

def id
  @id
end

#limitObject (readonly)

Returns the value of attribute limit.



2
3
4
# File 'lib/track-r/iteration.rb', line 2

def limit
  @limit
end

#numberObject (readonly)

Returns the value of attribute number.



2
3
4
# File 'lib/track-r/iteration.rb', line 2

def number
  @number
end

#offsetObject (readonly)

Returns the value of attribute offset.



2
3
4
# File 'lib/track-r/iteration.rb', line 2

def offset
  @offset
end

#project_idObject (readonly)

Returns the value of attribute project_id.



2
3
4
# File 'lib/track-r/iteration.rb', line 2

def project_id
  @project_id
end

#start_date(format = "%m/%d/%Y") ⇒ Object (readonly)

Returns the value of attribute start_date.



2
3
4
# File 'lib/track-r/iteration.rb', line 2

def start_date
  @start_date
end

#storiesObject (readonly)

Returns the value of attribute stories.



2
3
4
# File 'lib/track-r/iteration.rb', line 2

def stories
  @stories
end

#tokenObject (readonly)

Returns the value of attribute token.



2
3
4
# File 'lib/track-r/iteration.rb', line 2

def token
  @token
end

#typeObject (readonly)

Returns the value of attribute type.



2
3
4
# File 'lib/track-r/iteration.rb', line 2

def type
  @type
end

Class Method Details

.find(options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/track-r/iteration.rb', line 4

def self.find(options={})
  @token = options[:token] || Token.new
  if options.include?(:project_id)
    @project_id = options[:project_id]
    api_url = "#{CONFIG[:api_location]}/projects/#{@project_id}/iterations/#{options.include?(:type) ? options[:type] : ""}"
    iterations = (Hpricot(open(api_url, {"X-TrackerToken" => @token.to_s}))/'iteration').map do |iteration|
      Iteration.new(:iteration => iteration, :project_id => @project_id)
    end
  end
end