Class: UkAccountValidator::ModulusWeight

Inherits:
Object
  • Object
show all
Defined in:
lib/uk_account_validator/modulus_weight.rb

Constant Summary collapse

COLUMN_SIZES =

the size of each column

[6, 7, 9, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 3]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sort_code_start, sort_code_end, modulus, u, v, w, x, y, z, a, b, c, d, e, f, g, h, exception) ⇒ ModulusWeight

Returns a new instance of ModulusWeight.



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/uk_account_validator/modulus_weight.rb', line 22

def initialize(sort_code_start, sort_code_end, modulus, u, v, w, x, y, z,
      a, b, c, d, e, f, g, h, exception)

  @sort_code_start = sort_code_start
  @sort_code_end   = sort_code_end
  @modulus         = modulus
  @exception       = exception

  @u, @v, @w, @x, @y, @z, @a, @b, @c, @d, @e, @f, @g, @h =
    [u.to_i, v.to_i, w.to_i, x.to_i, y.to_i, z.to_i, a.to_i, b.to_i, c.to_i,
     d.to_i, e.to_i, f.to_i, g.to_i, h.to_i]
end

Instance Attribute Details

#aObject (readonly)

Returns the value of attribute a.



3
4
5
# File 'lib/uk_account_validator/modulus_weight.rb', line 3

def a
  @a
end

#bObject (readonly)

Returns the value of attribute b.



3
4
5
# File 'lib/uk_account_validator/modulus_weight.rb', line 3

def b
  @b
end

#cObject (readonly)

Returns the value of attribute c.



3
4
5
# File 'lib/uk_account_validator/modulus_weight.rb', line 3

def c
  @c
end

#dObject (readonly)

Returns the value of attribute d.



3
4
5
# File 'lib/uk_account_validator/modulus_weight.rb', line 3

def d
  @d
end

#eObject (readonly)

Returns the value of attribute e.



3
4
5
# File 'lib/uk_account_validator/modulus_weight.rb', line 3

def e
  @e
end

#exceptionObject (readonly)

Returns the value of attribute exception.



3
4
5
# File 'lib/uk_account_validator/modulus_weight.rb', line 3

def exception
  @exception
end

#fObject (readonly)

Returns the value of attribute f.



3
4
5
# File 'lib/uk_account_validator/modulus_weight.rb', line 3

def f
  @f
end

#gObject (readonly)

Returns the value of attribute g.



3
4
5
# File 'lib/uk_account_validator/modulus_weight.rb', line 3

def g
  @g
end

#hObject (readonly)

Returns the value of attribute h.



3
4
5
# File 'lib/uk_account_validator/modulus_weight.rb', line 3

def h
  @h
end

#modulusObject (readonly)

Returns the value of attribute modulus.



3
4
5
# File 'lib/uk_account_validator/modulus_weight.rb', line 3

def modulus
  @modulus
end

#sort_code_endObject (readonly)

Returns the value of attribute sort_code_end.



3
4
5
# File 'lib/uk_account_validator/modulus_weight.rb', line 3

def sort_code_end
  @sort_code_end
end

#sort_code_startObject (readonly)

Returns the value of attribute sort_code_start.



3
4
5
# File 'lib/uk_account_validator/modulus_weight.rb', line 3

def sort_code_start
  @sort_code_start
end

#uObject (readonly)

Returns the value of attribute u.



3
4
5
# File 'lib/uk_account_validator/modulus_weight.rb', line 3

def u
  @u
end

#vObject (readonly)

Returns the value of attribute v.



3
4
5
# File 'lib/uk_account_validator/modulus_weight.rb', line 3

def v
  @v
end

#wObject (readonly)

Returns the value of attribute w.



3
4
5
# File 'lib/uk_account_validator/modulus_weight.rb', line 3

def w
  @w
end

#xObject (readonly)

Returns the value of attribute x.



3
4
5
# File 'lib/uk_account_validator/modulus_weight.rb', line 3

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



3
4
5
# File 'lib/uk_account_validator/modulus_weight.rb', line 3

def y
  @y
end

#zObject (readonly)

Returns the value of attribute z.



3
4
5
# File 'lib/uk_account_validator/modulus_weight.rb', line 3

def z
  @z
end

Class Method Details

.from_line(definition_line) ⇒ Object

Parameters:

  • definition_line

    The line from valacdos.txt that defines this weight.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/uk_account_validator/modulus_weight.rb', line 10

def self.from_line(definition_line)
  # See https://www.ruby-forum.com/topic/184294#805359
  data = definition_line.unpack("A#{COLUMN_SIZES.join('A')}")

  data.map!(&:strip)

  @sort_code_start, @sort_code_end, @modulus, @u, @v, @w, @x,
    @y, @z, @a, @b, @c, @d, @e, @f, @g, @h, @exception = data

  ModulusWeight.new(*data)
end