Module: JamfRubyExtensions::String::Conversions

Included in:
String
Defined in:
lib/jamf/ruby_extensions/string/conversions.rb

Instance Method Summary collapse

Instance Method Details

#j_to_boolBoolean?

Convert the strings “true” and “false” (after stripping whitespace and downcasing) to TrueClass and FalseClass respectively

Return nil if any other string.

Returns:

  • (Boolean, nil)

    the boolean value



38
39
40
41
42
43
# File 'lib/jamf/ruby_extensions/string/conversions.rb', line 38

def j_to_bool
  case strip.downcase
  when 'true' then true
  when 'false' then false
  end # case
end

#j_to_pathnamePathname

Convert a String to a Pathname object

Returns:



57
58
59
# File 'lib/jamf/ruby_extensions/string/conversions.rb', line 57

def j_to_pathname
  Pathname.new self
end

#j_to_timestampTime

Convert a string to a Jamf::Timestamp object

Returns:

  • (Time)

    the time represented by the string.



49
50
51
# File 'lib/jamf/ruby_extensions/string/conversions.rb', line 49

def j_to_timestamp
  Jamf::Timestamp.new self
end