Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/jss-api/compatibility.rb,
lib/jss-api/ruby_extensions/string.rb
Instance Method Summary collapse
- #force_encoding(args = nil) ⇒ Object
-
#jss_to_bool ⇒ Boolean?
Convert the strings “true” and “false” (after stripping whitespace and downcasing) to TrueClass and FalseClass respectively.
-
#jss_to_time ⇒ Time
Convert a string to a Time object.
Instance Method Details
#force_encoding(args = nil) ⇒ Object
64 |
# File 'lib/jss-api/compatibility.rb', line 64 def force_encoding(args = nil); self; end |
#jss_to_bool ⇒ Boolean?
Convert the strings “true” and “false” (after stripping whitespace and downcasing) to TrueClass and FalseClass respectively
Return nil if any other string.
36 37 38 39 40 41 42 |
# File 'lib/jss-api/ruby_extensions/string.rb', line 36 def jss_to_bool case self.strip.downcase when "true" then return true when "false" then return false else return nil end # case end |
#jss_to_time ⇒ Time
Convert a string to a Time object
returns nil if not parsable by JSS::parse_datetime
50 51 52 53 54 55 56 |
# File 'lib/jss-api/ruby_extensions/string.rb', line 50 def jss_to_time begin JSS.parse_time self rescue return nil end end |