Class: Pione::Lang::CompoundFeature
- Inherits:
-
FeaturePiece
- Object
- StructX
- Piece
- FeaturePiece
- Pione::Lang::CompoundFeature
- Defined in:
- lib/pione/lang/feature-expr.rb
Overview
CompoundFeature represents conjunction of feature pieces.
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from FeaturePiece
Methods inherited from Piece
#eval, piece_type_name, #textize
Methods included from Util::Positionable
#line_and_column, #pos, #set_source_position
Class Method Details
.build(piece1, piece2) ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/pione/lang/feature-expr.rb', line 130 def build(piece1, piece2) # unify features if they are same return piece1 if piece1 == piece2 # append if either feature is compound return piece1.add(piece2) if piece1.is_a?(CompoundFeature) return piece2.add(piece1) if piece2.is_a?(CompoundFeature) # create new compound feature new(pieces: Set.new([piece1, piece2])) end |
Instance Method Details
#add(piece) ⇒ Object
145 146 147 148 149 150 151 |
# File 'lib/pione/lang/feature-expr.rb', line 145 def add(piece) if piece.is_a?(CompoundFeature) set(pieces: pieces + piece.pieces) else set(pieces: pieces + Set.new([piece])) end end |