Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/jss/compatibility.rb,
lib/jss/ruby_extensions/string.rb

Instance Method Summary collapse

Instance Method Details

#force_encoding(args = nil) ⇒ Object



64
# File 'lib/jss/compatibility.rb', line 64

def force_encoding(args = nil); self; end

#jss_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



36
37
38
39
40
41
# File 'lib/jss/ruby_extensions/string.rb', line 36

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

#jss_to_pathnamePathname

Convert a String to a Pathname object

Returns:



59
60
61
# File 'lib/jss/ruby_extensions/string.rb', line 59

def jss_to_pathname
  Pathname.new self
end

#jss_to_timeTime

Convert a string to a Time object

returns nil if not parsable by JSS::parse_datetime

Returns:

  • (Time)

    the time represented by the string.



49
50
51
52
53
# File 'lib/jss/ruby_extensions/string.rb', line 49

def jss_to_time
  JSS.parse_time self
rescue
  return nil
end