Class: Saphyr::Fields::IpField
- Defined in:
- lib/saphyr/fields/ip_field.rb
Overview
The IP field type
Allowed options is: :kind in (:any, :ipv4, :ipv6)
:any: can be an ipv4 or ipv6 (default):ipv4: must be an ipv4:ipv6: must be an ipv6
Constant Summary collapse
- PREFIX =
'ip'- EXPECTED_TYPES =
String- AUTHORIZED_OPTIONS =
[:kind]
Constants inherited from FieldBase
FieldBase::DEFAULT_OPTS, FieldBase::DEFAULT_OPT_VALUES, FieldBase::EXCLUSIVE_OPTIONS, FieldBase::NOT_EQUALS_OPTIONS, FieldBase::NOT_SUP_OPTIONS, FieldBase::NOT_SUP_OR_EQUALS_OPTIONS, FieldBase::REQUIRED_ONE_OF_OPTIONS, FieldBase::REQUIRED_OPTIONS
Constants included from Asserts::ErrorConstants
Asserts::ErrorConstants::ERR_BAD_FORMAT, Asserts::ErrorConstants::ERR_EQ, Asserts::ErrorConstants::ERR_GT, Asserts::ErrorConstants::ERR_GTE, Asserts::ErrorConstants::ERR_IN, Asserts::ErrorConstants::ERR_LEN, Asserts::ErrorConstants::ERR_LT, Asserts::ErrorConstants::ERR_LTE, Asserts::ErrorConstants::ERR_MAX, Asserts::ErrorConstants::ERR_MIN, Asserts::ErrorConstants::ERR_NOT_EMPTY, Asserts::ErrorConstants::ERR_NOT_NULLABLE, Asserts::ErrorConstants::ERR_REGEXP, Asserts::ErrorConstants::ERR_SIZE_EQ, Asserts::ErrorConstants::ERR_SIZE_LEN, Asserts::ErrorConstants::ERR_SIZE_MAX, Asserts::ErrorConstants::ERR_SIZE_MIN, Asserts::ErrorConstants::ERR_TYPE
Instance Attribute Summary
Attributes inherited from FieldBase
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ IpField
constructor
A new instance of IpField.
Methods inherited from FieldBase
#authorized_options, #default?, #err, #exclusive_options, #expected_types, #not_equals_options, #not_sup_options, #not_sup_or_equals_options, #nullable?, #prefix, #required?, #required_one_of_options, #required_options, #validate
Methods included from Asserts::StringAssert
Methods included from Asserts::NumericAssert
#assert_numeric_gt, #assert_numeric_gte, #assert_numeric_lt, #assert_numeric_lte
Methods included from Asserts::SizeAssert
#assert_size_len, #assert_size_max, #assert_size_min
Methods included from Asserts::BaseAssert
#assert_boolean, #assert_class, #assert_eq, #assert_in, #assert_not_empty
Constructor Details
#initialize(opts = {}) ⇒ IpField
Returns a new instance of IpField.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/saphyr/fields/ip_field.rb', line 16 def initialize(opts={}) if opts[:kind].nil? opts[:kind] = :any else unless [:any, :ipv4, :ipv6].include? opts[:kind] raise Saphyr::Error.new 'Bad IP kind option must be one of :any, :ipv4, :ipv6' end end super opts end |