Module: Casing
- Included in:
- Camel, Pascal, Underscore
- Defined in:
- lib/casing/camel.rb,
lib/casing/casing.rb,
lib/casing/pascal.rb,
lib/casing/camel/hash.rb,
lib/casing/underscore.rb,
lib/casing/camel/array.rb,
lib/casing/pascal/hash.rb,
lib/casing/camel/string.rb,
lib/casing/pascal/array.rb,
lib/casing/controls/hash.rb,
lib/casing/pascal/string.rb,
lib/casing/controls/array.rb,
lib/casing/controls/string.rb,
lib/casing/underscore/hash.rb,
lib/casing/underscore/array.rb,
lib/casing/underscore/string.rb
Defined Under Namespace
Modules: Controls
Classes: Camel, Error, Pascal, Underscore
Instance Method Summary
collapse
Instance Method Details
#!(val, include_values: nil, symbol_to_string: nil) ⇒ Object
TODO: Remove deprecated actuator [Kelsey, Thu Oct 08 2015]
24
25
26
|
# File 'lib/casing/casing.rb', line 24
def !(val, include_values: nil, symbol_to_string: nil)
call(val, include_values: include_values, symbol_to_string: symbol_to_string)
end
|
#call(val, include_values: nil, symbol_to_string: nil) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/casing/casing.rb', line 4
def call(val, include_values: nil, symbol_to_string: nil)
case val
when ::Hash
self::Hash.(val, include_values: include_values, symbol_to_string: symbol_to_string)
when ::Array
self::Array.(val, include_values: include_values, symbol_to_string: symbol_to_string)
when ::String
self::String.(val, include_values: include_values, symbol_to_string: symbol_to_string)
when ::Symbol
self::String.(val, include_values: include_values, symbol_to_string: symbol_to_string)
else
val
end
end
|
#case?(val, include_values: nil, symbol_to_string: nil) ⇒ Boolean
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/casing/casing.rb', line 28
def case?(val, include_values: nil, symbol_to_string: nil)
include_values ||= false
symbol_to_string ||= false
case val
when ::Array
val.each do |v|
cased = case?(v, include_values: include_values, symbol_to_string: symbol_to_string)
return false unless cased
end
when ::Hash
val.each do |k, v|
value_cased = value_cased?(k, symbol_to_string: symbol_to_string)
return false unless value_cased
cased = case?(v, include_values: include_values, symbol_to_string: symbol_to_string)
return false unless cased
end
else
if include_values
value_cased = value_cased?(val, symbol_to_string: symbol_to_string)
return false unless value_cased
end
end
true
end
|
#value_cased?(val, symbol_to_string: nil) ⇒ Boolean
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/casing/casing.rb', line 58
def value_cased?(val, symbol_to_string: nil)
symbol_to_string ||= false
if symbol_to_string && val.is_a?(Symbol)
return false
end
val = val.to_s
val.split.each do |v|
cased = match?(v)
return false unless cased
end
true
end
|