class String
Constants
- FALSES
- TRUES
Public Instance Methods
to_a(delimiter: " ")
click to toggle source
# File lib/ext/string.rb, line 15 def to_a(delimiter: " ") split(delimiter) end
to_b(invalid_value_behaviour: proc { nil })
click to toggle source
# File lib/ext/string.rb, line 7 def to_b(invalid_value_behaviour: proc { nil }) value = strip.downcase return true if TRUES.include?(value) return false if FALSES.include?(value) invalid_value_behaviour.call end
to_h(arr_sep: " ", key_sep: ":")
click to toggle source
# File lib/ext/string.rb, line 19 def to_h(arr_sep: " ", key_sep: ":") split(arr_sep).each_with_object({}) do |e, hsh| key, value = e.split(key_sep) hsh[key] = value end end
to_n()
click to toggle source
# File lib/ext/string.rb, line 27 def to_n return to_f if self =~ /[0-9]+\.[0-9]+/ to_i end