Module: Nemo::Util

Defined in:
lib/nemo/util.rb

Overview

Utility methods and objects

Defined Under Namespace

Modules: Accessors Classes: BlankSlate, ObjectCollector

Class Method Summary collapse

Class Method Details

.pascal_case(value) ⇒ Object

Format string as PascalCase (my_var, myVar become MyVar)



9
10
11
# File 'lib/nemo/util.rb', line 9

def pascal_case(value)
  value.to_s.split('_').collect{ |w| w[0,1].upcase+w[1..-1] }.join
end

.to_bool(value) ⇒ Object

Converts a value to true or false

True

true, :true, "true", :yes, "yes"

False

false, :false, "false", :no, "no", nil

Otherwise (value && true) is applied



20
21
22
23
24
# File 'lib/nemo/util.rb', line 20

def to_bool(value)
  value = false if [:false, 'false', :no, 'no', nil].include?(value)
  value = true if [:true, 'true', :yes, 'yes'].include?(value)
  value && true
end