Class: Rudelo::Parsers::SetLogicTransform
- Inherits:
-
SetValueTransform
- Object
- Parslet::Transform
- SetValueTransform
- Rudelo::Parsers::SetLogicTransform
- Defined in:
- lib/rudelo/parsers/set_logic_transform.rb
Defined Under Namespace
Classes: CardinalityExpr, EmptyExpr, MatchExpr, SetConstructionExpr, SetLogicExpr, SetOp
Instance Attribute Summary collapse
-
#in_set ⇒ Object
Returns the value of attribute in_set.
-
#set_value ⇒ Object
Returns the value of attribute set_value.
Class Method Summary collapse
Instance Method Summary collapse
- #apply(obj, context = nil) ⇒ Object
-
#initialize(in_set = ::Set.new, &block) ⇒ SetLogicTransform
constructor
A new instance of SetLogicTransform.
Constructor Details
#initialize(in_set = ::Set.new, &block) ⇒ SetLogicTransform
Returns a new instance of SetLogicTransform.
17 18 19 20 21 |
# File 'lib/rudelo/parsers/set_logic_transform.rb', line 17 def initialize(in_set=::Set.new, &block) @in_set = in_set.dup # the dup is vital because we are going to be pointery later @set_value = SetValueTransform.new super() end |
Instance Attribute Details
#in_set ⇒ Object
Returns the value of attribute in_set.
16 17 18 |
# File 'lib/rudelo/parsers/set_logic_transform.rb', line 16 def in_set @in_set end |
#set_value ⇒ Object
Returns the value of attribute set_value.
16 17 18 |
# File 'lib/rudelo/parsers/set_logic_transform.rb', line 16 def set_value @set_value end |
Class Method Details
.translate_op(op) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/rudelo/parsers/set_logic_transform.rb', line 89 def self.translate_op(op) case op when '#=', 'cardinality-equals', 'same-as', '='; :"==" when '#<','cardinality-less-than'; :< when '<','proper-subset'; :proper_subset? when '#>','cardinality-greater-than'; :> when '>', 'proper-superset'; :proper_superset? when '<=', 'subset'; :subset? when '>=', 'superset'; :superset? when 'intersection'; :& when 'union'; :+ when 'difference'; :- when 'exclusive'; :'^' else op.to_sym end end |
Instance Method Details
#apply(obj, context = nil) ⇒ Object
23 24 25 |
# File 'lib/rudelo/parsers/set_logic_transform.rb', line 23 def apply(obj, context=nil) super @set_value.apply(obj, context), {in_set: @in_set} end |