Module: Applitools::Utils
- Extended by:
- Utils
- Included in:
- Utils
- Defined in:
- lib/applitools/utils/utils.rb,
lib/applitools/utils/image_utils.rb,
lib/applitools/utils/image_delta_compressor.rb
Defined Under Namespace
Modules: ImageDeltaCompressor, ImageUtils
Constant Summary
collapse
- QUADRANTS_COUNT =
4
Instance Method Summary
collapse
Instance Method Details
#camelcase(str) ⇒ Object
14
15
16
17
|
# File 'lib/applitools/utils/utils.rb', line 14
def camelcase(str)
tokens = str.split('_')
uncapitalize(tokens.shift) + tokens.map(&:capitalize).join
end
|
#camelcase_hash_keys(hash) ⇒ Object
33
34
35
|
# File 'lib/applitools/utils/utils.rb', line 33
def camelcase_hash_keys(hash)
convert_hash_keys(hash, :camelcase)
end
|
#uncapitalize(str) ⇒ Object
10
11
12
|
# File 'lib/applitools/utils/utils.rb', line 10
def uncapitalize(str)
str[0, 1].downcase + str[1..-1]
end
|
#underscore(str) ⇒ Object
6
7
8
|
# File 'lib/applitools/utils/utils.rb', line 6
def underscore(str)
str.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').gsub(/([a-z\d])([A-Z])/, '\1_\2').tr('-', '_').downcase
end
|
#underscore_hash_keys(hash) ⇒ Object
29
30
31
|
# File 'lib/applitools/utils/utils.rb', line 29
def underscore_hash_keys(hash)
convert_hash_keys(hash, :underscore)
end
|
#wrap(object) ⇒ Object
19
20
21
22
23
24
25
26
27
|
# File 'lib/applitools/utils/utils.rb', line 19
def wrap(object)
if object.nil?
[]
elsif object.respond_to?(:to_ary)
object.to_ary || [object]
else
[object]
end
end
|