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? Also known as: jss_to_bool

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

Return nil if any other string.

Returns:

  • the boolean value



20
21
22
23
24
25
# File 'lib/jamf/ruby_extensions/string/conversions.rb', line 20

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

#j_to_pathnamePathname Also known as: jss_to_pathname

Convert a String to a Pathname object

Returns:



53
54
55
# File 'lib/jamf/ruby_extensions/string/conversions.rb', line 53

def j_to_pathname
  Pathname.new self
end

#j_to_timeTime Also known as: jss_to_time

Convert a string to a Time object

Returns:

  • the time represented by the string, or nil

See Also:

  • Jamf.parse_time


42
43
44
45
46
# File 'lib/jamf/ruby_extensions/string/conversions.rb', line 42

def j_to_time
  Jamf.parse_time self
rescue
  nil
end

#j_to_timestampTime

Convert a string to a Jamf::Timestamp object

Returns:

  • the time represented by the string.



32
33
34
# File 'lib/jamf/ruby_extensions/string/conversions.rb', line 32

def j_to_timestamp
  Jamf::Timestamp.new self
end