class BBS::Windows::Form::Field
One field of a Form, made from its descriptor: the widget that holds the value, its height and where it goes. ::for picks the kind.
Attributes
The field’s key in Form#values, and the widget holding its value.
The field’s key in Form#values, and the widget holding its value.
Public Class Methods
Source
# File lib/bbs/windows/form/fields.rb, line 14 def self.for(descriptor) { textarea: TextAreaField, checkbox: CheckboxField }.fetch(descriptor[:type], InputField).new(descriptor) end
The field for descriptor: a TextAreaField, a CheckboxField or, by default, an InputField.
Source
# File lib/bbs/windows/form/fields.rb, line 19 def initialize(descriptor) @descriptor = descriptor @key = descriptor[:key] @widget = build end
Builds the field’s widgets from descriptor.
Public Instance Methods
Source
# File lib/bbs/windows/form/fields.rb, line 32 def grows? = false
Whether the field takes the rows a form has to spare.
Source
# File lib/bbs/windows/form/fields.rb, line 29 def height = 1
The rows the field takes at its natural size.
Source
# File lib/bbs/windows/form/fields.rb, line 35 def labelled? = false
Whether the field has a label left of it (see Form label width).
# File lib/bbs/windows/form/fields.rb, line 42 def place(x, width, y, _rows, _label_width) = @widget.layout(x, y, width, 1)
Lays the field out from column x, width wide, on row y, rows high, its input label_width columns right of a label.
Source
# File lib/bbs/windows/form/fields.rb, line 38 def value = @widget.value
The field’s value.
Source
# File lib/bbs/windows/form/fields.rb, line 26 def widgets = [@widget]
The widgets the form adds for the field, in order.