Skip to content

Commit

Permalink
[api] Move status values into constant
Browse files Browse the repository at this point in the history
  • Loading branch information
bgeuken committed Jul 21, 2015
1 parent 316ca61 commit 2127ee9
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/api/app/models/buildresult.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
class Buildresult < ActiveXML::Node

Avail_status_values = %w(succeeded failed unresolvable broken blocked dispatching scheduled
building finished signing disabled excluded locked deleting unknown)
AVAIL_STATUS_VALUES = [
"succeeded",
"failed",
"unresolvable",
"broken",
"blocked",
"dispatching",
"scheduled",
"building",
"finished",
"signing",
"disabled",
"excluded",
"locked",
"deleting",
"unknown"
]

@@status_hash = nil

def self.avail_status_values
Avail_status_values
AVAIL_STATUS_VALUES
end

def self.code2index(code)
unless @@status_hash
@@status_hash = Hash.new
Avail_status_values.each_with_index do |s,index|
AVAIL_STATUS_VALUES.each_with_index do |s,index|
@@status_hash[s] = index
end
end
Expand All @@ -20,7 +36,7 @@ def self.code2index(code)
end

def self.index2code(index)
Avail_status_values[index]
AVAIL_STATUS_VALUES[index]
end

end

0 comments on commit 2127ee9

Please sign in to comment.