Skip to content

Commit

Permalink
CompoundPredicate - styling
Browse files Browse the repository at this point in the history
  • Loading branch information
asaf schers committed Dec 1, 2017
1 parent e5fa4dd commit 2fa3b21
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/scoruby/predicates/compound_predicate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
module Scoruby
module Predicates
class CompoundPredicate

attr_reader :field

def initialize(pred_xml)
Expand All @@ -24,23 +23,27 @@ def true?(features)
end

def missing?(features)
@field.any? {|f| !features.keys.include?(f)}
@field.any? { |f| !features.keys.include?(f) }
end

private

def surrogate?(features)
return @predicates[1].true?(features) if @predicates[0].missing?(features)
return @predicates[1].true?(features) if first_missing?(features)
@predicates[0].true?(features)
end

def first_missing?(features)
@predicates[0].missing?(features)
end

def or?(features)
@predicates.any? {|p| p.true?(features)}
@predicates.any? { |p| p.true?(features) }
end

def and?(features)
@predicates.all? {|p| p.true?(features)}
@predicates.all? { |p| p.true?(features) }
end
end
end
end
end

0 comments on commit 2fa3b21

Please sign in to comment.