rut_chileno 0.4 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/rut_chileno.rb +18 -0
  2. metadata +3 -3
data/lib/rut_chileno.rb CHANGED
@@ -1,9 +1,17 @@
1
+ ##
2
+ #All functions are just defined statically in this module
1
3
  module RUT
2
4
 
5
+ ##
6
+ #Returns boolean wether the given string is a valid Digito Verificador character or not
3
7
  def digitoValido(dv)
4
8
  ['0','1','2','3','4','5','6','7','8','9','k','K'].include?(dv)
5
9
  end
6
10
 
11
+ ##
12
+ #Every R.U.T. has a single valid Digito Verificador which is calculated based on its digits
13
+ #
14
+ #Given a R.U.T. this function returns its Digito Verificador as a string
7
15
  def getDigito(rut)
8
16
  dvr='0'
9
17
  suma=0
@@ -26,6 +34,10 @@ module RUT
26
34
  end
27
35
  end
28
36
 
37
+ ##
38
+ #Given a R.U.T. including its Digito Verificador (whatever the format, i.e. with or without points & hyphens)
39
+ #
40
+ #This function returns boolean wether the Digito Verificador matches the R.U.T. or not
29
41
  def digitoCorrecto(crut)
30
42
  return false if crut.size < 2
31
43
  if crut.size > 2
@@ -42,11 +54,15 @@ module RUT
42
54
  dvr.to_s==dv.downcase
43
55
  end
44
56
 
57
+ ##
58
+ #Strips a R.U.T. format (points & hyphens)
45
59
  def quitarFormato(rut)
46
60
  rut=rut.delete "."
47
61
  rut=rut.delete "-"
48
62
  end
49
63
 
64
+ ##
65
+ #Given a R.U.T. (whatever the format, i.e. with or without points & hyphens) this method returns boolean wether it is valid or not
50
66
  def validar(texto)
51
67
  texto=self.quitarFormato(texto)
52
68
  return false if texto.size < 2
@@ -81,6 +97,8 @@ module RUT
81
97
  return digitoCorrecto(texto)
82
98
  end
83
99
 
100
+ ##
101
+ #This method will give a raw R.U.T. string its proper format adding the right points & hyphens
84
102
  def formatear
85
103
  #TODO
86
104
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rut_chileno
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.4'
4
+ version: '0.5'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-02 00:00:00.000000000 Z
12
+ date: 2013-05-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: test/unit
@@ -73,5 +73,5 @@ rubyforge_project:
73
73
  rubygems_version: 1.8.25
74
74
  signing_key:
75
75
  specification_version: 3
76
- summary: formateo y validacion R.U.T.
76
+ summary: format & validate chilean R.U.T.
77
77
  test_files: []