Class: PTLog::Pivotal::Story

Inherits:
Object
  • Object
show all
Defined in:
lib/ptlog/pivotal/story.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(story_id) ⇒ Story

Returns a new instance of Story.



8
9
10
11
12
# File 'lib/ptlog/pivotal/story.rb', line 8

def initialize(story_id)
  @num = story_id
  @story = Pivotal::API.story(story_id)
  @labels = @story['labels'].map { |label| label['name'] } if @story['labels'].is_a?(Array)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/ptlog/pivotal/story.rb', line 22

def method_missing(meth)
  if @story.has_key?(meth.to_s)
    @story[meth.to_s]
  else
    super
  end
end

Instance Attribute Details

#numObject (readonly)

Returns the value of attribute num.



6
7
8
# File 'lib/ptlog/pivotal/story.rb', line 6

def num
  @num
end

Class Method Details

.get(id) ⇒ Object



30
31
32
33
34
# File 'lib/ptlog/pivotal/story.rb', line 30

def self.get(id)
  return @stories[id] if defined?(@stories) and @stories[id]
  @stories ||= {}
  @stories[id] = new(id)
end

Instance Method Details

#invalid?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/ptlog/pivotal/story.rb', line 14

def invalid?
  @story['kind'] == 'error'
end

#valid?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/ptlog/pivotal/story.rb', line 18

def valid?
  !invalid?
end