Class: Sandals::NumberField

Inherits:
Object
  • Object
show all
Includes:
Actionable, FieldValidation
Defined in:
lib/sandals/view.rb

Instance Attribute Summary collapse

Attributes included from FieldValidation

#error

Instance Method Summary collapse

Methods included from FieldValidation

#error_id, #invalid?

Constructor Details

#initialize(id, label, value:, action:, error: nil) ⇒ NumberField

Returns a new instance of NumberField.



362
363
364
365
366
367
368
# File 'lib/sandals/view.rb', line 362

def initialize(id, label, value:, action:, error: nil)
  @id = id
  @label = label.to_s
  @value = value
  initialize_error(error)
  @action = action
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



360
361
362
# File 'lib/sandals/view.rb', line 360

def id
  @id
end

#labelObject (readonly)

Returns the value of attribute label.



360
361
362
# File 'lib/sandals/view.rb', line 360

def label
  @label
end

#valueObject (readonly)

Returns the value of attribute value.



360
361
362
# File 'lib/sandals/view.rb', line 360

def value
  @value
end

Instance Method Details

#change(value) ⇒ Object



370
371
372
# File 'lib/sandals/view.rb', line 370

def change(value)
  execute_action(number(value))
end