Module: JamfRubyExtensions::String::Conversions
- Included in:
- String
- Defined in:
- lib/jamf/ruby_extensions/string/conversions.rb
Instance Method Summary collapse
-
#j_to_bool ⇒ Boolean?
(also: #jss_to_bool)
Convert the strings “true” and “false” (after stripping whitespace and downcasing) to TrueClass and FalseClass respectively.
-
#j_to_pathname ⇒ Pathname
(also: #jss_to_pathname)
Convert a String to a Pathname object.
-
#j_to_time ⇒ Time
(also: #jss_to_time)
Convert a string to a Time object.
-
#j_to_timestamp ⇒ Time
Convert a string to a Jamf::Timestamp object.
Instance Method Details
#j_to_bool ⇒ Boolean? 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.
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_pathname ⇒ Pathname Also known as: jss_to_pathname
Convert a String to a Pathname object
71 72 73 |
# File 'lib/jamf/ruby_extensions/string/conversions.rb', line 71 def j_to_pathname Pathname.new self end |
#j_to_time ⇒ Time Also known as: jss_to_time
Convert a string to a Time object
60 61 62 63 64 |
# File 'lib/jamf/ruby_extensions/string/conversions.rb', line 60 def j_to_time Jamf.parse_time self rescue nil end |