Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/hpath/filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def initialize(string = nil)
[:and, []]
else
case string
when /!=/ then [:inequality, string.split("!=")]
when /=/ then [:equality, string.split("=")]
when /</ then [:less_than, string.split("<")]
when />/ then [:greater_than, string.split(">")]
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/hpath/parser/filter_expression_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down