class ActiveLdap::Schema::Syntaxes::BitString

Public Instance Methods

normalize_value(value) click to toggle source
# File lib/active_ldap/schema/syntaxes.rb, line 56
def normalize_value(value)
  if value.is_a?(String) and /\A[01]*\z/ =~ value
    "'#{value}'B"
  else
    value
  end
end
type_cast(value) click to toggle source
# File lib/active_ldap/schema/syntaxes.rb, line 47
def type_cast(value)
  return nil if value.nil?
  if /\A'([01]*)'B\z/ =~ value.to_s
    $1
  else
    value
  end
end

Private Instance Methods

validate_normalized_value(value, original_value) click to toggle source
# File lib/active_ldap/schema/syntaxes.rb, line 65
def validate_normalized_value(value, original_value)
  if /\A'/ !~ value
    return _("%s doesn't have the first \"'\"") % original_value.inspect
  end

  if /'B\z/ !~ value
    return _("%s doesn't have the last \"'B\"") % original_value.inspect
  end

  if /([^01])/ =~ value[1..-3]
    return _("%s has invalid character '%s'") % [value.inspect, $1]
  end

  nil
end