sipp 0.1.1 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: afc06bf3d738f114978538c4871eb471445325d3
4
- data.tar.gz: 1622501a3713dc46419d4ab9bd3df6ccddf88f43
3
+ metadata.gz: 2b070afc9f31b4d758cffb81730c1cf2f66c8f77
4
+ data.tar.gz: 0172f9196c6f4207143e8c18a8b2dfa5d159f761
5
5
  SHA512:
6
- metadata.gz: 5482401382b1cb73967fd3d3b14b557c0fab803581adc2b6f8e4606c0078435452171337e4224297d15d852a515365f80c2d81b617707cee152e3daf34ba81ae
7
- data.tar.gz: e1db25fff8d9692e97f566891c35e9c001c772697fe3ed572290f19e6b2d176da6344bc846559eb2d4672fc8a891b41ed611803fe478e99b2678f48cf7098042
6
+ metadata.gz: 4f1dd007f766d6ec94dc27e07ee3f5115974a09547b4875bbe13f4625685234d378c34a9df427d25ac63e55895e64db9f0b880ed0a9631e8ea519b12c4ef5ee4
7
+ data.tar.gz: ad55e279ed148f69b247afe77300d7d75bfc216720677662a5676a0db9521e6b36eb9bdd75b735e3826a2d651faac05e929b8a2ac46b55eec9b2c370d4f9b6c1
data/lib/sipp/code.rb CHANGED
@@ -26,61 +26,86 @@ module SIPP
26
26
  end
27
27
 
28
28
  def category
29
- CATEGORY[code[0]] if valid?
29
+ validate_category
30
+ CATEGORY[code[0]]
31
+ rescue CategoryError => e
32
+ nil
30
33
  end
31
34
 
32
35
  def type
33
- TYPE[code[1]] if valid?
36
+ validate_type
37
+ TYPE[code[1]]
38
+ rescue TypeError => e
39
+ nil
34
40
  end
35
41
 
36
42
  def transmission_drive
37
- TRANSMISSION_DRIVE[code[2]] if valid?
43
+ validate_transmission_drive
44
+ TRANSMISSION_DRIVE[code[2]]
45
+ rescue TransmissionDriveError => e
46
+ nil
38
47
  end
39
48
 
40
49
  def transmission
41
- TRANSMISSION[code[2]] if valid?
50
+ validate_transmission_drive
51
+ TRANSMISSION[code[2]]
52
+ rescue TransmissionDriveError => e
53
+ nil
42
54
  end
43
55
 
44
56
  def transmission_manual?
45
- if valid?
46
- 'Manual' == transmission ? true : false # TODO fix magic string
47
- else
48
- nil
49
- end
57
+ validate_transmission_drive
58
+ 'Manual' == transmission ? true : false # TODO fix magic string
59
+ rescue TransmissionDriveError => e
60
+ nil
50
61
  end
62
+
51
63
  def transmission_auto?
52
- if valid?
53
- 'Auto' == transmission ? true : false # TODO fix magic string
54
- else
55
- nil
56
- end
64
+ validate_transmission_drive
65
+ 'Auto' == transmission ? true : false # TODO fix magic string
66
+ rescue TransmissionDriveError => e
67
+ nil
57
68
  end
69
+
58
70
  def drive
59
- DRIVE[code[2]] if valid?
71
+ validate_transmission_drive
72
+ DRIVE[code[2]]
73
+ rescue TransmissionDriveError => e
74
+ nil
60
75
  end
61
76
 
62
77
  def fuel_ac
63
- FUEL_AC[code[3]] if valid?
78
+ validate_fuel_ac
79
+ FUEL_AC[code[3]]
80
+ rescue FuelACError => e
81
+ nil
64
82
  end
65
83
 
66
84
  def fuel
67
- FUEL[code[3]] if valid?
85
+ validate_fuel_ac
86
+ FUEL[code[3]]
87
+ rescue FuelACError => e
88
+ nil
68
89
  end
69
90
 
70
91
  def ac
71
- AC[code[3]] if valid?
92
+ validate_fuel_ac
93
+ AC[code[3]]
94
+ rescue FuelACError => e
95
+ nil
72
96
  end
73
97
 
74
98
  def ac?
75
- if valid?
76
- 'Air' == ac ? true : false # TODO fix magic string
77
- else
78
- nil
79
- end
99
+ validate_fuel_ac
100
+ 'Air' == ac ? true : false # TODO fix magic string
101
+ rescue FuelACError => e
102
+ nil
80
103
  end
81
104
 
82
105
  def to_s
83
- [category, type, transmission_drive, fuel_ac].join(' - ')
106
+ [category, type, transmission_drive, fuel_ac].map{|c| c.nil? ? '#N/A' : c}.join(' - ')
107
+ rescue CodeError, CategoryError, TypeError, TransmissionDriveError, FuelACError
108
+ ''
84
109
  end
85
110
 
86
111
  private
data/lib/sipp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module SIPP
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.4"
3
3
  end
data/lib/sipp.rb CHANGED
@@ -10,6 +10,6 @@ module SIPP
10
10
  # Your code goes here...
11
11
  end
12
12
 
13
- require 'active_support/all'
13
+ require 'active_support/core_ext/object'
14
14
  require "sipp/code"
15
15
  require "sipp/dictionary"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sipp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Buslaev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-31 00:00:00.000000000 Z
11
+ date: 2022-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler