Class: Pv::Story

Inherits:
Object show all
Defined in:
lib/pv/story.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from_pivotal_story) ⇒ Story

Returns a new instance of Story.



9
10
11
12
13
14
# File 'lib/pv/story.rb', line 9

def initialize from_pivotal_story
  @pivotal_story = from_pivotal_story
  %w(id story_type requested_by owned_by current_state name description estimate).each do |attr|
    self.send "#{attr}=", from_pivotal_story.send(attr)
  end
end

Instance Attribute Details

#current_stateObject

Returns the value of attribute current_state.



5
6
7
# File 'lib/pv/story.rb', line 5

def current_state
  @current_state
end

#descriptionObject

Returns the value of attribute description.



5
6
7
# File 'lib/pv/story.rb', line 5

def description
  @description
end

#estimateObject

Returns the value of attribute estimate.



5
6
7
# File 'lib/pv/story.rb', line 5

def estimate
  @estimate
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/pv/story.rb', line 5

def id
  @id
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/pv/story.rb', line 5

def name
  @name
end

#owned_byObject

Returns the value of attribute owned_by.



5
6
7
# File 'lib/pv/story.rb', line 5

def owned_by
  @owned_by
end

#pivotal_storyObject (readonly)

Returns the value of attribute pivotal_story.



7
8
9
# File 'lib/pv/story.rb', line 7

def pivotal_story
  @pivotal_story
end

#requested_byObject

Returns the value of attribute requested_by.



5
6
7
# File 'lib/pv/story.rb', line 5

def requested_by
  @requested_by
end

#story_typeObject

Returns the value of attribute story_type.



5
6
7
# File 'lib/pv/story.rb', line 5

def story_type
  @story_type
end

Class Method Details

.find(by_id) ⇒ Object



16
17
18
# File 'lib/pv/story.rb', line 16

def self.find by_id
  new Pv.tracker.stories.select { |s| s.id == by_id.to_i }.first
end

.present?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/pv/story.rb', line 20

def self.present?
  not nil?
end

Instance Method Details

#renderObject

Render this Story in plain text.



25
26
27
28
29
# File 'lib/pv/story.rb', line 25

def render
  source = IO.read "#{Pv.root}/lib/templates/story.txt.erb"
  template = ERB.new(source)
  template.result(binding)
end

#update(status) ⇒ Object



31
32
33
# File 'lib/pv/story.rb', line 31

def update(status)
  @pivotal_story.update(current_state: status)
end