Class: Plinko::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/plinko/validator.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Validator

Returns a new instance of Validator.



5
6
7
# File 'lib/plinko/validator.rb', line 5

def initialize(value)
  self.value = value
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



3
4
5
# File 'lib/plinko/validator.rb', line 3

def value
  @value
end

Class Method Details

.validate(value) ⇒ Object



9
10
11
# File 'lib/plinko/validator.rb', line 9

def self.validate(value)
  new(value).validate
end

Instance Method Details

#error_messageObject



25
26
27
# File 'lib/plinko/validator.rb', line 25

def error_message
  "An error occurred."
end

#validateObject



13
14
15
16
17
18
19
# File 'lib/plinko/validator.rb', line 13

def validate
  if validation
    value
  else
    [value, [error_message]]      
  end
end

#validationObject



21
22
23
# File 'lib/plinko/validator.rb', line 21

def validation
  true
end