Class: Aequitas::Rule::Numericalness::Integer
- Inherits:
-
Aequitas::Rule
- Object
- Aequitas::Rule
- Aequitas::Rule::Numericalness::Integer
- Includes:
- Aequitas::Rule::Numericalness
- Defined in:
- lib/aequitas/rule/numericalness/integer.rb
Instance Attribute Summary
Attributes inherited from Aequitas::Rule
#attribute_name, #custom_message, #guard, #skip_condition
Attributes included from Equalizable
Instance Method Summary collapse
Methods included from Aequitas::Rule::Numericalness
included, #initialize, rules_for, scour_options_of_keys, #valid?
Methods inherited from Aequitas::Rule
#attribute_value, #execute?, #initialize, rules_for, #skip?, #validate, #violation_data, #violation_info, #violation_values
Methods included from Equalizable
Instance Method Details
#expected ⇒ Object
12 13 14 |
# File 'lib/aequitas/rule/numericalness/integer.rb', line 12 def expected /\A[+-]?\d+\z/ end |
#valid_numericalness?(value) ⇒ Boolean
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/aequitas/rule/numericalness/integer.rb', line 16 def valid_numericalness?(value) # XXX: workaround for jruby. This is needed because the jruby # compiler optimizes a bit too far with magic variables like $~. # the value.send line sends $~. Inserting this line makes sure the # jruby compiler does not optimise here. # see http://jira.codehaus.org/browse/JRUBY-3765 $~ = nil if RUBY_PLATFORM[/java/] value_as_string(value) =~ expected rescue ArgumentError # TODO: figure out better solution for: can't compare String with Integer true end |
#violation_type(resource) ⇒ Object
30 31 32 |
# File 'lib/aequitas/rule/numericalness/integer.rb', line 30 def violation_type(resource) :not_an_integer end |