Last active
          August 30, 2017 20:37 
        
      - 
      
- 
        Save jwaldrip/e118818abd5ee0fe59ea9da74eaad9ec to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def self.reserved_value?(value, checks = 0) | |
| return true if YAML::RESERVED_VALUES.includes?(value) | |
| just_value = value.ljust(5, 'x') | |
| case {just_value[0], just_value[1], just_value[2], just_value[3], just_value[4]} | |
| when {.ascii_number?, .ascii_number?, .ascii_number?, .ascii_number?, '-'} | |
| (Time::Format::ISO_8601_DATE_TIME.parse(value) rescue false) | |
| when {.ascii_number?, _, _, _, _}, | |
| {'-', .ascii_number?, _, _, _}, | |
| {'+', .ascii_number?, _, _, _}, | |
| {'.', .ascii_number?, _, _, _}, | |
| {'-', '.', .ascii_number?, _, _}, | |
| {'+', '.', .ascii_number?, _, _} | |
| clean_value = value.gsub('_', "") | |
| clean_value.to_f64? || clean_value.to_i64?(prefix: true) | |
| end | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment