Class: Bug

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/bug.rb

Overview

Fields are name (string), priority (int), area (string), status (boolean).

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.search(term = nil) ⇒ Object

Searches for a bug with given name or id



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/bug.rb', line 21

def self.search(term=nil)
  # Get the needed search term if the argument is a hash
  term = self.get_term(term) if term.kind_of?(Hash)
  
  # Find the right bug
  bug = self.get_bug_from_id_or_name(term)
  
  # What to do if the bug isn't found
  if bug == nil
    raise Exception, "Bug not found with name '#{term}'." if term.kind_of?(String)
    raise Exception, "Bug not found with id \##{term}." if term.kind_of?(Fixnum)
  end
  
  # Return the bug
  return bug
end

Instance Method Details

#closed?Boolean

Is the bug closed?

Returns:

  • (Boolean)


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

def closed?
  status
end

#open?Boolean Also known as: opened?

Is the bug open?

Returns:

  • (Boolean)


11
12
13
# File 'lib/bug.rb', line 11

def open?
  !status
end