Class: IbmCase
- Inherits:
-
Object
- Object
- IbmCase
- Defined in:
- lib/ibm_case.rb
Instance Attribute Summary collapse
-
#branch_id ⇒ Object
Returns the value of attribute branch_id.
-
#country_code ⇒ Object
Returns the value of attribute country_code.
-
#country_name ⇒ Object
Returns the value of attribute country_name.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#phm ⇒ Object
readonly
Returns the value of attribute phm.
-
#rcms ⇒ Object
readonly
Returns the value of attribute rcms.
-
#type ⇒ Object
readonly
(pmr, rcms or poject).
Instance Method Summary collapse
-
#decode ⇒ Object
-rcms transfer is for a RCMS problem -id references a RCMS id, provided by IBM support format: rrrrrrr.ccc r: RCMS number c: country code.
- #id_nice ⇒ Object
-
#initialize(case_id) ⇒ IbmCase
constructor
A new instance of IbmCase.
- #pmr? ⇒ Boolean
- #project? ⇒ Boolean
- #rcms? ⇒ Boolean
- #to_ibmsdduu ⇒ Object
- #validate ⇒ Object
Constructor Details
#initialize(case_id) ⇒ IbmCase
14 15 16 17 18 19 20 |
# File 'lib/ibm_case.rb', line 14 def initialize(case_id) id = case_id.gsub(',', '.') @id = id self.decode() end |
Instance Attribute Details
#branch_id ⇒ Object
Returns the value of attribute branch_id.
7 8 9 |
# File 'lib/ibm_case.rb', line 7 def branch_id @branch_id end |
#country_code ⇒ Object
Returns the value of attribute country_code.
5 6 7 |
# File 'lib/ibm_case.rb', line 5 def country_code @country_code end |
#country_name ⇒ Object
Returns the value of attribute country_name.
6 7 8 |
# File 'lib/ibm_case.rb', line 6 def country_name @country_name end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
9 10 11 |
# File 'lib/ibm_case.rb', line 9 def id @id end |
#phm ⇒ Object (readonly)
Returns the value of attribute phm.
10 11 12 |
# File 'lib/ibm_case.rb', line 10 def phm @phm end |
#rcms ⇒ Object (readonly)
Returns the value of attribute rcms.
11 12 13 |
# File 'lib/ibm_case.rb', line 11 def rcms @rcms end |
#type ⇒ Object (readonly)
(pmr, rcms or poject)
8 9 10 |
# File 'lib/ibm_case.rb', line 8 def type @type end |
Instance Method Details
#decode ⇒ Object
-rcms transfer is for a RCMS problem
-id references a RCMS id, provided by IBM support
format: rrrrrrr.ccc
r: RCMS number c: country code
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/ibm_case.rb', line 47 def decode() if match = %r{^(\w{3})(\w{7})$}.match(@id) #website ID format @country_code = match[1] @rcms = match[2] @type = 'rcms' elsif match2 = %r{^(\w{7})\.(\w{3})$}.match(@id) @rcms = match2[1] @country_code = match2[2] @type = 'rcms' elsif match = %r{^(\w{5})\.(\w{3})\.(\w{3})$}.match(@id) @phm = match[1] @branch_id = match[2] @country_code = match[3] @type = 'pmr' elsif match = %r{^(\w{5})$}.match(@id) @phm = match[1] @type = 'pmr' else pp @id raise 'wrong id, it is not rcms or pmr' end end |
#id_nice ⇒ Object
92 93 94 95 96 97 98 99 100 101 |
# File 'lib/ibm_case.rb', line 92 def id_nice self.validate if (@type == 'rcms') return @rcms + '.' + @country_code elsif (@type == 'pmr') return @phm + '.' + @branch_id + '.' + @country_code end end |
#pmr? ⇒ Boolean
27 28 29 30 |
# File 'lib/ibm_case.rb', line 27 def pmr? return true if self.type == 'rcms' false end |
#project? ⇒ Boolean
32 33 34 35 |
# File 'lib/ibm_case.rb', line 32 def project? return true if self.type == 'project' false end |
#rcms? ⇒ Boolean
22 23 24 25 |
# File 'lib/ibm_case.rb', line 22 def rcms? return true if self.type == 'rcms' false end |
#to_ibmsdduu ⇒ Object
103 104 105 106 107 |
# File 'lib/ibm_case.rb', line 103 def to_ibmsdduu self.validate '-' + @type + " -id=" + self.id_nice end |
#validate ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/ibm_case.rb', line 72 def validate unless @type == 'pmr' or @type == 'rcms' or @type == 'project' raise 'wrong type' end if @type == 'pmr' raise 'not setup phm' if @phm.nil? raise 'not setup branch_id' if @branch_id.nil? raise 'not setup country_code' if @country_code.nil? end if @type == 'rcms' raise 'not setup rcms' if @rcms.nil? raise 'not setup country_code' if @country_code.nil? end end |