Class: Kanrisuru::Util
- Inherits:
-
Object
show all
- Defined in:
- lib/kanrisuru/util.rb,
lib/kanrisuru/util/bits.rb,
lib/kanrisuru/util/signal.rb,
lib/kanrisuru/util/dmi_type.rb,
lib/kanrisuru/util/os_family.rb,
lib/kanrisuru/util/fs_mount_opts.rb
Defined Under Namespace
Classes: Bits, DmiType, FsMountOpts, OsFamily, Signal
Class Method Summary
collapse
Class Method Details
.array_join_string(arg, field = ',') ⇒ Object
19
20
21
|
# File 'lib/kanrisuru/util.rb', line 19
def self.array_join_string(arg, field = ',')
arg.instance_of?(Array) ? arg.join(field) : arg
end
|
.blank?(value) ⇒ Boolean
11
12
13
|
# File 'lib/kanrisuru/util.rb', line 11
def self.blank?(value)
value.respond_to?(:empty?) ? value.empty? : !value
end
|
.camelize(string) ⇒ Object
38
39
40
41
42
43
|
# File 'lib/kanrisuru/util.rb', line 38
def self.camelize(string)
string = string.to_s
string = string.sub(/^[a-z\d]*/, &:capitalize)
string.gsub!(%r{(?:_|(/))([a-z\d]*)}i) { "#{Regexp.last_match(1)}#{Regexp.last_match(2).capitalize}" }
string
end
|
.numeric?(value) ⇒ Boolean
32
33
34
35
36
|
# File 'lib/kanrisuru/util.rb', line 32
def self.numeric?(value)
!Float(value).nil?
rescue StandardError
false
end
|
.present?(value) ⇒ Boolean
15
16
17
|
# File 'lib/kanrisuru/util.rb', line 15
def self.present?(value)
!Kanrisuru::Util.blank?(value)
end
|
.string_join_array(arg, field = ',') ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'lib/kanrisuru/util.rb', line 23
def self.string_join_array(arg, field = ',')
Kanrisuru.logger.info do
'DEPRECATION WARNING: string_join_array will be removed in the upcoming major release. Use array_join_string instead.'
end
array = arg.instance_of?(String) ? [arg] : arg
array.join(field)
end
|