Class: Rabarber::Input::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/rabarber/input/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, error_type = Rabarber::InvalidArgumentError, error_message = default_error_message) ⇒ Base

Returns a new instance of Base.



8
9
10
11
12
# File 'lib/rabarber/input/base.rb', line 8

def initialize(value, error_type = Rabarber::InvalidArgumentError, error_message = default_error_message)
  @value = value
  @error_type = error_type
  @error_message = error_message
end

Instance Attribute Details

#error_messageObject (readonly)

Returns the value of attribute error_message.



6
7
8
# File 'lib/rabarber/input/base.rb', line 6

def error_message
  @error_message
end

#error_typeObject (readonly)

Returns the value of attribute error_type.



6
7
8
# File 'lib/rabarber/input/base.rb', line 6

def error_type
  @error_type
end

#valueObject (readonly)

Returns the value of attribute value.



6
7
8
# File 'lib/rabarber/input/base.rb', line 6

def value
  @value
end

Instance Method Details

#processObject



14
15
16
# File 'lib/rabarber/input/base.rb', line 14

def process
  valid? ? processed_value : raise_error
end

#valid?Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


18
19
20
# File 'lib/rabarber/input/base.rb', line 18

def valid?
  raise NotImplementedError
end