class Pione::Lang::FeatureSequence
FeatureSequence
represents disjunction of feature pieces.
Public Class Methods
of(*args)
click to toggle source
# File lib/pione/lang/feature-expr.rb, line 169 def of(*args) args.each {|arg| raise ArgumentError(arg) unless arg.is_a?(FeaturePiece)} args.size > 0 ? new(args) : new([EmptyFeature.new]) end
Public Instance Methods
_match(provider_piece, request_piece)
click to toggle source
# File lib/pione/lang/feature-expr.rb, line 210 def _match(provider_piece, request_piece) # apply eliminations _provider_piece, _request_piece = Eliminator.new(provider_piece, request_piece).eliminate # features are matched if both pieces are empty return true if _provider_piece.is_a?(EmptyFeature) and _request_piece.is_a?(EmptyFeature) # feature are unmatched if peaces are not elminated return false if provider_piece == _provider_piece and request_piece == _request_piece # next return _match(_provider_piece, _request_piece) end
concat(other)
click to toggle source
Calls superclass method
# File lib/pione/lang/feature-expr.rb, line 177 def concat(other) acceptable = feature_type.nil? or feature_type == :both other_acceptable = other.feature_type.nil? or other.feature_type == :both if feature_type == other.feature_type or acceptable or other_acceptable super(other) else raise SequenceAttributeError.new(other) end end
match(other)
click to toggle source
Return true if the feature accepts other feature.
# File lib/pione/lang/feature-expr.rb, line 188 def match(other) provider_pieces = pieces request_pieces = other.pieces if feature_type == :request or other.feature_type == :provider provider_pieces = other.pieces request_pieces = pieces end provider_pieces = [EmptyFeature.new] if provider_pieces.empty? request_pieces = [EmptyFeature.new] if request_pieces.empty? provider_pieces.any? do |provider_piece| request_pieces.any? do |request_piece| _match(provider_piece, request_piece) end end end
Also aliased as: "==="