rcap 2.7.0 → 2.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. checksums.yaml +5 -5
  2. data/.ruby-version +1 -1
  3. data/lib/rcap.rb +2 -0
  4. data/lib/rcap/alert.rb +4 -2
  5. data/lib/rcap/base/alert.rb +57 -55
  6. data/lib/rcap/base/area.rb +19 -13
  7. data/lib/rcap/base/circle.rb +6 -4
  8. data/lib/rcap/base/event_code.rb +2 -0
  9. data/lib/rcap/base/geocode.rb +2 -0
  10. data/lib/rcap/base/info.rb +65 -59
  11. data/lib/rcap/base/parameter.rb +6 -4
  12. data/lib/rcap/base/point.rb +4 -2
  13. data/lib/rcap/base/polygon.rb +8 -6
  14. data/lib/rcap/base/resource.rb +9 -9
  15. data/lib/rcap/cap_1_0/alert.rb +22 -20
  16. data/lib/rcap/cap_1_0/area.rb +2 -0
  17. data/lib/rcap/cap_1_0/circle.rb +2 -0
  18. data/lib/rcap/cap_1_0/event_code.rb +3 -1
  19. data/lib/rcap/cap_1_0/geocode.rb +3 -1
  20. data/lib/rcap/cap_1_0/info.rb +3 -1
  21. data/lib/rcap/cap_1_0/parameter.rb +3 -1
  22. data/lib/rcap/cap_1_0/point.rb +2 -0
  23. data/lib/rcap/cap_1_0/polygon.rb +2 -0
  24. data/lib/rcap/cap_1_0/resource.rb +2 -0
  25. data/lib/rcap/cap_1_1/alert.rb +4 -2
  26. data/lib/rcap/cap_1_1/area.rb +2 -0
  27. data/lib/rcap/cap_1_1/circle.rb +2 -0
  28. data/lib/rcap/cap_1_1/event_code.rb +3 -1
  29. data/lib/rcap/cap_1_1/geocode.rb +3 -1
  30. data/lib/rcap/cap_1_1/info.rb +34 -32
  31. data/lib/rcap/cap_1_1/parameter.rb +2 -0
  32. data/lib/rcap/cap_1_1/point.rb +2 -0
  33. data/lib/rcap/cap_1_1/polygon.rb +2 -0
  34. data/lib/rcap/cap_1_1/resource.rb +6 -4
  35. data/lib/rcap/cap_1_2/alert.rb +4 -2
  36. data/lib/rcap/cap_1_2/area.rb +2 -0
  37. data/lib/rcap/cap_1_2/circle.rb +2 -0
  38. data/lib/rcap/cap_1_2/event_code.rb +3 -1
  39. data/lib/rcap/cap_1_2/geocode.rb +3 -1
  40. data/lib/rcap/cap_1_2/info.rb +42 -38
  41. data/lib/rcap/cap_1_2/parameter.rb +2 -0
  42. data/lib/rcap/cap_1_2/point.rb +2 -0
  43. data/lib/rcap/cap_1_2/polygon.rb +2 -0
  44. data/lib/rcap/cap_1_2/resource.rb +8 -5
  45. data/lib/rcap/config.rb +2 -0
  46. data/lib/rcap/custom_validators.rb +11 -11
  47. data/lib/rcap/extensions/array.rb +2 -0
  48. data/lib/rcap/extensions/date.rb +3 -1
  49. data/lib/rcap/extensions/date_time.rb +4 -1
  50. data/lib/rcap/extensions/float.rb +2 -0
  51. data/lib/rcap/extensions/integer.rb +2 -0
  52. data/lib/rcap/extensions/nil_class.rb +2 -0
  53. data/lib/rcap/extensions/string.rb +3 -1
  54. data/lib/rcap/extensions/time.rb +3 -0
  55. data/lib/rcap/formatters/yaml.rb +3 -2
  56. data/lib/rcap/info.rb +2 -0
  57. data/lib/rcap/utilities.rb +7 -9
  58. data/lib/rcap/validation.rb +11 -9
  59. data/lib/rcap/version.rb +3 -1
  60. metadata +3 -4
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RCAP
2
4
  module CAP_1_1
3
5
  # A Parameter object is valid if
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RCAP
2
4
  module CAP_1_1
3
5
  # A Point object is valid if
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RCAP
2
4
  module CAP_1_1
3
5
  # A Polygon object is valid if
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RCAP
2
4
  module CAP_1_1
3
5
  # A Resource object is valid if
@@ -6,8 +8,8 @@ module RCAP
6
8
  # @return [String] Dereferenced URI - contents of URI Base64 encoded
7
9
  attr_accessor(:deref_uri)
8
10
 
9
- DEREF_URI_ELEMENT_NAME = 'derefUri'
10
- DEREF_URI_XPATH = "cap:#{ DEREF_URI_ELEMENT_NAME }"
11
+ DEREF_URI_ELEMENT_NAME = 'derefUri'
12
+ DEREF_URI_XPATH = "cap:#{DEREF_URI_ELEMENT_NAME}"
11
13
 
12
14
  # @return [REXML::Element]
13
15
  def to_xml_element
@@ -50,7 +52,7 @@ module RCAP
50
52
  end
51
53
  end
52
54
 
53
- DEREF_URI_YAML = 'Derefrenced URI Data'
55
+ DEREF_URI_YAML = 'Derefrenced URI Data'
54
56
 
55
57
  def to_yaml_data
56
58
  RCAP.attribute_values_to_hash([RESOURCE_DESC_YAML, @resource_desc],
@@ -75,7 +77,7 @@ module RCAP
75
77
  end
76
78
  end
77
79
 
78
- DEREF_URI_KEY = 'deref_uri'
80
+ DEREF_URI_KEY = 'deref_uri'
79
81
 
80
82
  # @return [Hash]
81
83
  def to_h
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RCAP
2
4
  module CAP_1_2
3
5
  # An Alert object is valid if
@@ -12,9 +14,9 @@ module RCAP
12
14
  XMLNS = 'urn:oasis:names:tc:emergency:cap:1.2'
13
15
  CAP_VERSION = '1.2'
14
16
 
15
- STATUS_DRAFT = 'Draft'
17
+ STATUS_DRAFT = 'Draft'
16
18
  # Valid values for status
17
- VALID_STATUSES = [STATUS_ACTUAL, STATUS_EXERCISE, STATUS_SYSTEM, STATUS_TEST, STATUS_DRAFT]
19
+ VALID_STATUSES = [STATUS_ACTUAL, STATUS_EXERCISE, STATUS_SYSTEM, STATUS_TEST, STATUS_DRAFT].freeze
18
20
 
19
21
  # @return [String]
20
22
  def xmlns
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RCAP
2
4
  module CAP_1_2
3
5
  # An Area object is valid if
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RCAP
2
4
  module CAP_1_2
3
5
  # A Circle object is valid if
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RCAP
2
4
  module CAP_1_2
3
5
  # Subclass of {Parameter}
4
6
  class EventCode < RCAP::Base::EventCode
5
7
  XML_ELEMENT_NAME = 'eventCode'
6
- XPATH = "cap:#{ XML_ELEMENT_NAME }"
8
+ XPATH = "cap:#{XML_ELEMENT_NAME}"
7
9
 
8
10
  # @return [String]
9
11
  def xmlns
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RCAP
2
4
  module CAP_1_2
3
5
  # Subclass of {Parameter}
4
6
  class Geocode < RCAP::Base::Geocode
5
7
  XML_ELEMENT_NAME = 'geocode'
6
- XPATH = "cap:#{ XML_ELEMENT_NAME }"
8
+ XPATH = "cap:#{XML_ELEMENT_NAME}"
7
9
 
8
10
  # @return [String]
9
11
  def xmlns
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RCAP
2
4
  module CAP_1_2
3
5
  # In Info object is valid if
@@ -9,26 +11,28 @@ module RCAP
9
11
  # * all Resource objects in the resources collection are valid
10
12
  # * all Area objects in the areas collection are valid
11
13
  class Info < RCAP::Base::Info
12
- RESPONSE_TYPE_SHELTER = 'Shelter'
13
- RESPONSE_TYPE_EVACUATE = 'Evacuate'
14
- RESPONSE_TYPE_PREPARE = 'Prepare'
15
- RESPONSE_TYPE_EXECUTE = 'Execute'
16
- RESPONSE_TYPE_MONITOR = 'Monitor'
17
- RESPONSE_TYPE_ASSESS = 'Assess'
18
- RESPONSE_TYPE_NONE = 'None'
14
+ RESPONSE_TYPE_SHELTER = 'Shelter'
15
+ RESPONSE_TYPE_EVACUATE = 'Evacuate'
16
+ RESPONSE_TYPE_PREPARE = 'Prepare'
17
+ RESPONSE_TYPE_EXECUTE = 'Execute'
18
+ RESPONSE_TYPE_MONITOR = 'Monitor'
19
+ RESPONSE_TYPE_AVOID = 'Avoid'
20
+ RESPONSE_TYPE_ASSESS = 'Assess'
21
+ RESPONSE_TYPE_ALL_CLEAR = 'AllClear'
22
+ RESPONSE_TYPE_NONE = 'None'
19
23
  # Valid values for response_type
20
- VALID_RESPONSE_TYPES = [RESPONSE_TYPE_SHELTER, RESPONSE_TYPE_EVACUATE, RESPONSE_TYPE_PREPARE, RESPONSE_TYPE_EXECUTE, RESPONSE_TYPE_MONITOR, RESPONSE_TYPE_ASSESS, RESPONSE_TYPE_NONE]
24
+ VALID_RESPONSE_TYPES = [RESPONSE_TYPE_SHELTER, RESPONSE_TYPE_EVACUATE, RESPONSE_TYPE_PREPARE, RESPONSE_TYPE_EXECUTE, RESPONSE_TYPE_MONITOR, RESPONSE_TYPE_AVOID, RESPONSE_TYPE_ASSESS, RESPONSE_TYPE_ALL_CLEAR, RESPONSE_TYPE_NONE].freeze
21
25
 
22
26
  CERTAINTY_OBSERVED = 'Observed'
23
27
  # Valid valies for certainty
24
- VALID_CERTAINTIES = [CERTAINTY_OBSERVED, CERTAINTY_LIKELY, CERTAINTY_POSSIBLE, CERTAINTY_UNLIKELY, CERTAINTY_UNKNOWN]
28
+ VALID_CERTAINTIES = [CERTAINTY_OBSERVED, CERTAINTY_LIKELY, CERTAINTY_POSSIBLE, CERTAINTY_UNLIKELY, CERTAINTY_UNKNOWN].freeze
25
29
 
26
30
  RESPONSE_TYPE_ELEMENT_NAME = 'responseType'
27
- RESPONSE_TYPE_XPATH = "cap:#{ RESPONSE_TYPE_ELEMENT_NAME }"
31
+ RESPONSE_TYPE_XPATH = "cap:#{RESPONSE_TYPE_ELEMENT_NAME}"
28
32
 
29
33
  validates_length_of(:categories, minimum: 1)
30
34
  validates_inclusion_of_members_of(:response_types, in: VALID_RESPONSE_TYPES, allow_blank: true)
31
- validates_inclusion_of(:certainty, allow_nil: true, in: VALID_CERTAINTIES, message: "can only be assigned the following values: #{ VALID_CERTAINTIES.join(', ') }")
35
+ validates_inclusion_of(:certainty, allow_nil: true, in: VALID_CERTAINTIES, message: "can only be assigned the following values: #{VALID_CERTAINTIES.join(', ')}")
32
36
 
33
37
  # @return [Array<String>] Collection of textual response types; elements must be from {VALID_RESPONSE_TYPES}
34
38
  attr_reader(:response_types)
@@ -113,27 +117,27 @@ module RCAP
113
117
 
114
118
  # @return [String]
115
119
  def inspect
116
- info_inspect = "Language: #{ @language }\n"\
117
- "Categories: #{ @categories.to_s_for_cap }\n"\
118
- "Event: #{ @event }\n"\
119
- "Response Types: #{ @response_types.to_s_for_cap }\n"\
120
- "Urgency: #{ @urgency }\n"\
121
- "Severity: #{ @severity }\n"\
122
- "Certainty: #{ @certainty }\n"\
123
- "Audience: #{ @audience }\n"\
124
- "Event Codes: #{ @event_codes.inspect }\n"\
125
- "Effective: #{ @effective }\n"\
126
- "Onset: #{ @onset }\n"\
127
- "Expires: #{ @expires }\n"\
128
- "Sender Name: #{ @sender_name }\n"\
129
- "Headline: #{ @headline }\n"\
130
- "Description:\n" + @description.to_s.lines.map { |line| ' ' + line }.join("\n") + "\n"\
131
- "Instruction: #{ @instruction }\n"\
132
- "Web: #{ @web }\n"\
133
- "Contact: #{ @contact }\n"\
134
- "Parameters:\n" + @parameters.map { |parameter| ' ' + parameter.inspect }.join("\n") + "\n"\
135
- "Resources:\n" + @resources.map { |resource| ' ' + resource.inspect }.join("\n") + "\n"\
136
- "Area:\n" + @areas.map { |area| " #{ area }" }.join("\n") + "\n"
120
+ info_inspect = "Language: #{@language}\n"\
121
+ "Categories: #{@categories.to_s_for_cap}\n"\
122
+ "Event: #{@event}\n"\
123
+ "Response Types: #{@response_types.to_s_for_cap}\n"\
124
+ "Urgency: #{@urgency}\n"\
125
+ "Severity: #{@severity}\n"\
126
+ "Certainty: #{@certainty}\n"\
127
+ "Audience: #{@audience}\n"\
128
+ "Event Codes: #{@event_codes.inspect}\n"\
129
+ "Effective: #{@effective}\n"\
130
+ "Onset: #{@onset}\n"\
131
+ "Expires: #{@expires}\n"\
132
+ "Sender Name: #{@sender_name}\n"\
133
+ "Headline: #{@headline}\n"\
134
+ "Description:\n" + @description.to_s.lines.map { |line| ' ' + line }.join("\n") + "\n"\
135
+ "Instruction: #{@instruction}\n"\
136
+ "Web: #{@web}\n"\
137
+ "Contact: #{@contact}\n"\
138
+ "Parameters:\n" + @parameters.map { |parameter| ' ' + parameter.inspect }.join("\n") + "\n"\
139
+ "Resources:\n" + @resources.map { |resource| ' ' + resource.inspect }.join("\n") + "\n"\
140
+ "Area:\n" + @areas.map { |area| " #{area}" }.join("\n") + "\n"
137
141
  RCAP.format_lines_for_inspect('INFO', info_inspect)
138
142
  end
139
143
 
@@ -142,7 +146,7 @@ module RCAP
142
146
  #
143
147
  # @return [String]
144
148
  def to_s
145
- "#{ @event }(#{ @urgency }/#{ @severity }/#{ @certainty })"
149
+ "#{@event}(#{@urgency}/#{@severity}/#{@certainty})"
146
150
  end
147
151
 
148
152
  # @param [REXML::Element] info_xml_element
@@ -159,7 +163,7 @@ module RCAP
159
163
 
160
164
  # @return [Hash]
161
165
  def to_yaml_data
162
- parameter_to_hash = lambda { |hash, parameter| hash.merge(parameter.name => parameter.value) }
166
+ parameter_to_hash = ->(hash, parameter) { hash.merge(parameter.name => parameter.value) }
163
167
 
164
168
  RCAP.attribute_values_to_hash([LANGUAGE_YAML, @language],
165
169
  [CATEGORIES_YAML, @categories],
@@ -220,10 +224,10 @@ module RCAP
220
224
  [INSTRUCTION_KEY, @instruction],
221
225
  [WEB_KEY, @web],
222
226
  [CONTACT_KEY, @contact],
223
- [RESOURCES_KEY, @resources.map { |resource| resource.to_h }],
224
- [EVENT_CODES_KEY, @event_codes.map { |event_code| event_code.to_h }],
225
- [PARAMETERS_KEY, @parameters.map { |parameter| parameter.to_h }],
226
- [AREAS_KEY, @areas.map { |area| area.to_h }])
227
+ [RESOURCES_KEY, @resources.map(&:to_h)],
228
+ [EVENT_CODES_KEY, @event_codes.map(&:to_h)],
229
+ [PARAMETERS_KEY, @parameters.map(&:to_h)],
230
+ [AREAS_KEY, @areas.map(&:to_h)])
227
231
  end
228
232
 
229
233
  # @param [Hash] info_hash
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RCAP
2
4
  module CAP_1_2
3
5
  # A Parameter object is valid if
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RCAP
2
4
  module CAP_1_2
3
5
  # A Point object is valid if
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RCAP
2
4
  module CAP_1_2
3
5
  # A Polygon object is valid if
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RCAP
2
4
  module CAP_1_2
3
5
  # A Resource object is valid if
@@ -9,9 +11,9 @@ module RCAP
9
11
 
10
12
  validates_presence_of(:mime_type)
11
13
 
12
- DEREF_URI_ELEMENT_NAME = 'derefUri'
14
+ DEREF_URI_ELEMENT_NAME = 'derefUri'
13
15
 
14
- DEREF_URI_XPATH = "cap:#{ DEREF_URI_ELEMENT_NAME }"
16
+ DEREF_URI_XPATH = "cap:#{DEREF_URI_ELEMENT_NAME}"
15
17
 
16
18
  # @return [REXML::Element]
17
19
  def to_xml_element
@@ -54,7 +56,7 @@ module RCAP
54
56
  end
55
57
  end
56
58
 
57
- DEREF_URI_YAML = 'Derefrenced URI Data'
59
+ DEREF_URI_YAML = 'Derefrenced URI Data'
58
60
 
59
61
  # @param [Hash] options
60
62
  # @return [String]
@@ -65,7 +67,8 @@ module RCAP
65
67
  [MIME_TYPE_YAML, @mime_type],
66
68
  [DEREF_URI_YAML, @deref_uri],
67
69
  [SIZE_YAML, @size],
68
- [DIGEST_YAML, @digest]).to_yaml(options)
70
+ [DIGEST_YAML, @digest]
71
+ ).to_yaml(options)
69
72
  end
70
73
 
71
74
  # @param [Hash] resource_yaml_data
@@ -76,7 +79,7 @@ module RCAP
76
79
  end
77
80
  end
78
81
 
79
- DEREF_URI_KEY = 'deref_uri'
82
+ DEREF_URI_KEY = 'deref_uri'
80
83
 
81
84
  # @return [Hash]
82
85
  def to_h
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RCAP
2
4
  XML_PRETTY_PRINTER = REXML::Formatters::Pretty.new(2)
3
5
  XML_PRETTY_PRINTER.compact = true
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Validation
2
4
  module ClassMethods
3
5
  CAP_NUMBER_REGEX = Regexp.new('^-{0,1}\d*\.{0,1}\d+$')
@@ -27,7 +29,7 @@ module Validation
27
29
  }.merge!(attributes.extract_options!)
28
30
 
29
31
  validates_each(*attributes) do |object, attribute, collection|
30
- next if ( collection.nil? && options[:allow_nil]) || ( collection.empty? && options[:allow_empty])
32
+ next if (collection.nil? && options[:allow_nil]) || (collection.empty? && options[:allow_empty])
31
33
  unless collection.all? { |member| options[:in].include?(member) }
32
34
  object.errors[attribute] << options[:message]
33
35
  end
@@ -40,7 +42,7 @@ module Validation
40
42
  }.merge!(attributes.extract_options!)
41
43
 
42
44
  validates_each(*attributes) do |object, attribute, collection|
43
- next if ( collection.nil? && options[:allow_nil]) || ( collection.empty? && options[:allow_empty])
45
+ next if (collection.nil? && options[:allow_nil]) || (collection.empty? && options[:allow_empty])
44
46
  unless options[:minimum] && collection.length >= options[:minimum]
45
47
  object.errors[attribute] << options[:message]
46
48
  end
@@ -54,9 +56,7 @@ module Validation
54
56
 
55
57
  validates_each(*attributes) do |object, attribute, value|
56
58
  next if value.nil? && options[:allow_nil]
57
- unless value && value.valid?
58
- object.errors[attribute] << options[:message]
59
- end
59
+ object.errors[attribute] << options[:message] unless value&.valid?
60
60
  end
61
61
  end
62
62
 
@@ -66,8 +66,8 @@ module Validation
66
66
  }.merge!(attributes.extract_options!)
67
67
 
68
68
  validates_each(*attributes) do |object, attribute, collection|
69
- next if ( collection.nil? && options[:allow_nil]) || ( collection.empty? && options[:allow_empty])
70
- unless collection.all? { |element| element.valid? }
69
+ next if (collection.nil? && options[:allow_nil]) || (collection.empty? && options[:allow_empty])
70
+ unless collection.all?(&:valid?)
71
71
  object.errors[attribute] << options[:message]
72
72
  end
73
73
  end
@@ -107,16 +107,16 @@ module Validation
107
107
 
108
108
  def validates_numericality_of(*attributes)
109
109
  options = {
110
- message: 'is not a number or does not meet a conditional requirement',
110
+ message: 'is not a number or does not meet a conditional requirement'
111
111
  }.merge!(attributes.extract_options!)
112
112
 
113
113
  re = options[:only_integer] ? CAP_INTEGER_REGEX : CAP_NUMBER_REGEX
114
114
 
115
115
  validates_each(*attributes) do |object, attribute, value|
116
116
  next if value.nil? && options[:allow_nil]
117
- unless ( value.to_s =~ re) &&
118
- ( options[:greater_than].nil? || value && value > options[:greater_than]) &&
119
- ( options[:greater_than_or_equal].nil? || value && value >= options[:greater_than_or_equal])
117
+ unless (value.to_s =~ re) &&
118
+ (options[:greater_than].nil? || value && value > options[:greater_than]) &&
119
+ (options[:greater_than_or_equal].nil? || value && value >= options[:greater_than_or_equal])
120
120
  object.errors[attribute] << options[:message]
121
121
  end
122
122
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Array
2
4
  # Formats an array into a string suitable for a CAP message.
3
5
  #
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Date
2
- alias_method :inspect, :to_s
4
+ alias inspect to_s
3
5
 
4
6
  # Returns a string representaion of the time suitable for CAP.
5
7
  # @return [String]
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class DateTime
2
- alias_method :inspect, :to_s
4
+ alias inspect to_s
3
5
 
4
6
  # Returns a string representaion of the time suitable for CAP.
5
7
  # @return [String]
@@ -15,6 +17,7 @@ class DateTime
15
17
  end
16
18
 
17
19
  private
20
+
18
21
  def utc_hours_offset
19
22
  offset * 24
20
23
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Float
2
4
  def blank?
3
5
  false
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Integer
2
4
  def blank?
3
5
  false
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class NilClass
2
4
  def blank?
3
5
  true
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class String
2
4
  CAP_LIST_REGEX = Regexp.new('"([\w\s]+)"|(\S+)')
3
5
  WHITESPACE_REGEX = Regexp.new('^\s+$')
@@ -10,7 +12,7 @@ class String
10
12
  # "one".for_cap_list # => "one"
11
13
  # "two words".for_cap_list # => "\"two words\""
12
14
  def for_cap_list
13
- if self =~ /\s/
15
+ if /\s/.match?(self)
14
16
  '"' + self + '"'
15
17
  else
16
18
  self