diff --git a/lib/hpath/filter.rb b/lib/hpath/filter.rb index 6592b89..4803ef4 100644 --- a/lib/hpath/filter.rb +++ b/lib/hpath/filter.rb @@ -10,6 +10,7 @@ def initialize(string = nil) [:and, []] else case string + when /!=/ then [:inequality, string.split("!=")] when /=/ then [:equality, string.split("=")] when // then [:greater_than, string.split(">")] @@ -41,6 +42,13 @@ def applies?(object) elsif object.respond_to(key) object.send(key) == value end + elsif @type == :inequality + key, value = @operands + if object.is_a?(Hash) + object[key.to_s] != value.to_s + elsif object.respond_to(key) + object.send(key) != value + end end end end diff --git a/lib/hpath/parser/filter_expression_parser.rb b/lib/hpath/parser/filter_expression_parser.rb index e75ddd3..c460221 100644 --- a/lib/hpath/parser/filter_expression_parser.rb +++ b/lib/hpath/parser/filter_expression_parser.rb @@ -28,7 +28,7 @@ def parse(string) current_filter = Hpath::Filter.new parent = {} # look up table - string.gsub(/\s/, "").each_char do |char| + string.each_char do |char| unless special_character?(char) char_buffer << char else