Module: JSSRubyExtensions::String::Conversions
- Included in:
 - String
 
- Defined in:
 - lib/jss/ruby_extensions/string/conversions.rb
 
Instance Method Summary collapse
- 
  
    
      #jss_to_bool  ⇒ Boolean? 
    
    
  
  
  
  
  
  
  
  
  
    
Convert the strings “true” and “false” (after stripping whitespace and downcasing) to TrueClass and FalseClass respectively.
 - 
  
    
      #jss_to_pathname  ⇒ Pathname 
    
    
  
  
  
  
  
  
  
  
  
    
Convert a String to a Pathname object.
 - 
  
    
      #jss_to_time  ⇒ Time 
    
    
  
  
  
  
  
  
  
  
  
    
Convert a string to a Time object.
 
Instance Method Details
#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.
      38 39 40 41 42 43  | 
    
      # File 'lib/jss/ruby_extensions/string/conversions.rb', line 38 def jss_to_bool case strip.downcase when 'true' then true when 'false' then false end # case end  | 
  
#jss_to_pathname ⇒ Pathname
Convert a String to a Pathname object
      61 62 63  | 
    
      # File 'lib/jss/ruby_extensions/string/conversions.rb', line 61 def jss_to_pathname Pathname.new self end  | 
  
#jss_to_time ⇒ Time
Convert a string to a Time object
returns nil if not parsable by JSS::parse_datetime
      51 52 53 54 55  | 
    
      # File 'lib/jss/ruby_extensions/string/conversions.rb', line 51 def jss_to_time JSS.parse_time self rescue nil end  |