Class: OpenRosa::Fields::Input

Inherits:
Base
  • Object
show all
Defined in:
lib/open_rosa/fields/input.rb

Overview

Input field for text, numbers, dates, and other basic input types

Constant Summary collapse

VALID_TYPES =
i[
  string int decimal date time dateTime
  geopoint geotrace geoshape barcode binary intent
].freeze
REGEX_CALL =

Matches regex() calls with single- or double-quoted patterns

/regex\s*\(/
REGEX_WITH_PATTERN =
/regex\s*\(\s*[^,]+,\s*(?:'((?:[^'\\]|\\.)*)'|"((?:[^"\\]|\\.)*)")\s*\)/

Instance Attribute Summary collapse

Attributes inherited from Base

#default, #hint, #label, #name, #required

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ Input

Returns a new instance of Input.



18
19
20
21
22
23
24
25
# File 'lib/open_rosa/fields/input.rb', line 18

def initialize(name, options = {})
  super
  @type = options.fetch(:type, :string)
  @constraint = options[:constraint]
  @constraint_message = options[:constraint_message]

  validate!
end

Instance Attribute Details

#constraintObject (readonly)

Returns the value of attribute constraint.



7
8
9
# File 'lib/open_rosa/fields/input.rb', line 7

def constraint
  @constraint
end

#constraint_messageObject (readonly)

Returns the value of attribute constraint_message.



7
8
9
# File 'lib/open_rosa/fields/input.rb', line 7

def constraint_message
  @constraint_message
end

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/open_rosa/fields/input.rb', line 7

def type
  @type
end