<commit_before># -*- coding: utf-8 -*-
require 'httparty'
require 'json'
require 'htmlentities'

module VehicleCDMX
  class VehicleCDMX

    # constructor de clase

    def initialize(p)
      if p !~ /\A[a-z0-9]{1,14}\z/i
        @status = 'invalidPlate'
        return
      end
      @plate = p.upcase
      begin
        url = 'http://datos.labplc.mx/movilidad/vehiculos/' + @plate + '.json'
        res = HTTParty.get(url);
      rescue
        @status = 'apiGetError'
        return
      end
      if res.code != 200
        @status = 'apiHttpError'
        return
      end
      begin
        res = JSON.parse(res.body)
        @api = res['consulta']
      rescue
        @status = 'apiJsonError'
        return
      end
      @status = 'ok'
    end

    # accesores basicos

    def error
      if (@status == 'ok')
        return false
      end
      @status
    end

    def plate
      @plate
    end

    def plate_ending
      /\d(?!.*\d)/.match(@plate)[0]
    end

    def plate_ending_str
      plate_ending_str = { 
        '1' => 'uno', '2' => 'dos', '3' => 'tres', '4' => 'cuatro', 
        '5' => 'cinco', '6' => 'seis', '7' => 'siete', '8' => 'ocho',
        '9' => 'nueve', '0' => 'cero' }
      return plate_ending_str[self.plate_ending]
    end
<commit_msg>limpiamos placa y devolvemos errores estilo constantes (antes camel case)<commit_after># -*- coding: utf-8 -*-
require 'httparty'
require 'json'
require 'htmlentities'

module VehicleCDMX
  class VehicleCDMX

    # constructor de clase

    def initialize(p)
      p.gsub!(/[^0-9a-z ]/i, '')
      if p !~ /\A[a-z0-9]{1,14}\z/i
        @status = 'INVALID_PLATE'
        return
      end
      @plate = p.upcase
      begin
        url = 'http://datos.labplc.mx/movilidad/vehiculos/' + @plate + '.json'
        res = HTTParty.get(url);
      rescue
        @status = 'API_GET_ERROR'
        return
      end
      if res.code != 200
        @status = 'API_HTTP_ERROR'
        return
      end
      begin
        res = JSON.parse(res.body)
        @api = res['consulta']
      rescue
        @status = 'API_JSON_ERROR'
        return
      end
      @status = 'OK'
    end

    # accesores basicos

    def error
      if (@status == 'OK')
        return false
      end
      @status
    end

    def plate
      @plate
    end

    def plate_ending
      /\d(?!.*\d)/.match(@plate)[0]
    end

    def plate_ending_str
      plate_ending_str = { 
        '1' => 'uno', '2' => 'dos', '3' => 'tres', '4' => 'cuatro', 
        '5' => 'cinco', '6' => 'seis', '7' => 'siete', '8' => 'ocho',
        '9' => 'nueve', '0' => 'cero' }
      return plate_ending_str[self.plate_ending]
    end

{'fraction_non_alphanumeric': 0.15142428785607195, 'fraction_numerical': 0.015742128935532233, 'mean_word_length': 1.7686721991701244, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6586999', 'n_tokens_mistral': 988, 'n_tokens_neox': 946, 'n_words': 221}