Class: Bicho::History

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/bicho/history.rb

Overview

A collection of Changesets associated with a bug

Instance Method Summary collapse

Constructor Details

#initialize(client, data) ⇒ History

Returns a new instance of History.



132
133
134
135
# File 'lib/bicho/history.rb', line 132

def initialize(client, data)
  @client = client
  @data = data
end

Instance Method Details

#bugString

Returns The numeric id of the bug.

Returns:

  • (String)

    The numeric id of the bug



142
143
144
145
# File 'lib/bicho/history.rb', line 142

def bug
  @bug = @client.get_bug(@data['id']) unless @bug
  @bug
end

#bug_idObject



137
138
139
# File 'lib/bicho/history.rb', line 137

def bug_id
  @data['id']
end

#changesetsArray<ChangeSet>

Returns collection of changesets.

Returns:

  • (Array<ChangeSet>)

    collection of changesets



148
149
150
151
152
# File 'lib/bicho/history.rb', line 148

def changesets
  @data['history'].map do |changeset|
    ChangeSet.new(@client, changeset)
  end
end

#eachObject

iterate over each changeset



115
116
117
118
119
120
# File 'lib/bicho/history.rb', line 115

def each
  return enum_for(:each) unless block_given?
  changesets.each do |c|
    yield c
  end
end

#empty?Boolean

Returns true when there are no changesets.

Returns:

  • (Boolean)

    true when there are no changesets



128
129
130
# File 'lib/bicho/history.rb', line 128

def empty?
  changesets.empty?
end

#sizeFixnum

Returns number of changesets.

Returns:

  • (Fixnum)

    number of changesets



123
124
125
# File 'lib/bicho/history.rb', line 123

def size
  changesets.size
end

#to_sObject



154
155
156
157
158
159
160
161
# File 'lib/bicho/history.rb', line 154

def to_s
  buffer = StringIO.new
  buffer << "#{bug_id}\n"
  changesets.each do |cs|
    buffer << "#{cs}\n"
  end
  buffer.string
end