@@ -56,9 +56,7 @@ def initialize(operator:, value:, property: nil)
5656
5757 def match_trait_value? ( trait_value )
5858 # handle some exceptions
59- if @value . is_a? ( String ) && @value . match? ( /:semver$/ )
60- trait_value = Semantic ::Version . new ( trait_value . gsub ( /:semver$/ , '' ) )
61- end
59+ trait_value = Semantic ::Version . new ( trait_value . gsub ( /:semver$/ , '' ) ) if @value . is_a? ( String ) && @value . match? ( /:semver$/ )
6260
6361 return match_modulo_value ( trait_value ) if @operator == MODULO
6462
@@ -73,8 +71,8 @@ def format_to_type_of(input)
7371 {
7472 'String' => -> ( v ) { v . to_s } ,
7573 'Semantic::Version' => -> ( v ) { Semantic ::Version . new ( v . to_s . gsub ( /:semver$/ , '' ) ) } ,
76- 'TrueClass' => -> ( v ) { [ 'True' , 'true' , 'TRUE' , true , 1 , '1' ] . include? ( v ) ? true : false } ,
77- 'FalseClass' => -> ( v ) { [ 'False' , 'false' , 'FALSE' , false , 0 , '0' ] . include? ( v ) ? false : true } ,
74+ 'TrueClass' => -> ( v ) { [ 'True' , 'true' , 'TRUE' , true , 1 , '1' ] . include? ( v ) } ,
75+ 'FalseClass' => -> ( v ) { ! [ 'False' , 'false' , 'FALSE' , false , 0 , '0' ] . include? ( v ) } ,
7876 'Integer' => -> ( v ) { v . to_i } ,
7977 'Float' => -> ( v ) { v . to_f }
8078 } [ input . class . to_s ]
@@ -83,7 +81,7 @@ def format_to_type_of(input)
8381
8482 def match_modulo_value ( trait_value )
8583 divisor , remainder = @value . split ( '|' )
86- trait_value . is_a? ( Numeric ) && trait_value % divisor . to_f == remainder . to_f
84+ trait_value . is_a? ( Numeric ) && trait_value % divisor . to_f == remainder . to_f # rubocop:disable Lint/FloatComparison
8785 rescue StandardError
8886 false
8987 end
0 commit comments