Class: PivotalAPI::StoryTransition

Inherits:
Base
  • Object
show all
Defined in:
lib/pivotal-tracker-api/story_transition.rb

Direct Known Subclasses

StoryTransitions

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Base

#initialize, #to_json

Constructor Details

This class inherits a constructor from PivotalAPI::Base

Instance Attribute Details

#kindObject

Returns the value of attribute kind.



26
27
28
# File 'lib/pivotal-tracker-api/story_transition.rb', line 26

def kind
  @kind
end

#occurred_atObject

Returns the value of attribute occurred_at.



26
27
28
# File 'lib/pivotal-tracker-api/story_transition.rb', line 26

def occurred_at
  @occurred_at
end

#performed_by_idObject

Returns the value of attribute performed_by_id.



26
27
28
# File 'lib/pivotal-tracker-api/story_transition.rb', line 26

def performed_by_id
  @performed_by_id
end

#project_idObject

Returns the value of attribute project_id.



26
27
28
# File 'lib/pivotal-tracker-api/story_transition.rb', line 26

def project_id
  @project_id
end

#project_versionObject

Returns the value of attribute project_version.



26
27
28
# File 'lib/pivotal-tracker-api/story_transition.rb', line 26

def project_version
  @project_version
end

#stateObject

Returns the value of attribute state.



26
27
28
# File 'lib/pivotal-tracker-api/story_transition.rb', line 26

def state
  @state
end

#story_idObject

Returns the value of attribute story_id.



26
27
28
# File 'lib/pivotal-tracker-api/story_transition.rb', line 26

def story_id
  @story_id
end

Class Method Details

.from_json(json) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/pivotal-tracker-api/story_transition.rb', line 30

def from_json(json)
  return nil unless json
  if json.is_a?(Array)
    parse_json_story_transitions(json)
  else
    parse_json_story_transition(json)
  end
end

.parse_json_story_transition(json_story_transition) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/pivotal-tracker-api/story_transition.rb', line 47

def parse_json_story_transition(json_story_transition)
  new({
    state: json_story_transition[:state],
    story_id: json_story_transition[:story_id].to_i,
    project_id: json_story_transition[:project_id].to_i,
    project_version: json_story_transition[:project_version].to_i,
    occurred_at: (DateTime.parse(json_story_transition[:occurred_at]) if json_story_transition[:occurred_at]),
    performed_by_id: json_story_transition[:performed_by_id].to_i,
    kind: json_story_transition[:kind]
  })
end

.parse_json_story_transitions(json_story_transitions) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/pivotal-tracker-api/story_transition.rb', line 39

def parse_json_story_transitions(json_story_transitions)
  transitions = []
  json_story_transitions.each do |transition|
    transitions << parse_json_story_transition(transition)
  end
  transitions
end