Class: CSquare::Generator::BooleanOp
- Defined in:
- lib/csquare/generator/boolean_op.rb
Instance Attribute Summary
Attributes inherited from Op
Instance Method Summary collapse
- #decorated(args_types, return_type, default_type_symbol) ⇒ Object
-
#select_pattern(args_types, return_type) ⇒ Object
Determine which pattern to apply.
Methods inherited from BinaryOp
Methods inherited from Op
#[], #[]=, #has_key?, #initialize, #inspect
Constructor Details
This class inherits a constructor from CSquare::Generator::Op
Instance Method Details
#decorated(args_types, return_type, default_type_symbol) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/csquare/generator/boolean_op.rb', line 3 def decorated args_types, return_type, default_type_symbol result = super(args_types, return_type, default_type_symbol) return nil if result.nil? # Boolean operations always return booleans [result[0], :boolean] end |
#select_pattern(args_types, return_type) ⇒ Object
Determine which pattern to apply
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/csquare/generator/boolean_op.rb', line 12 def select_pattern args_types, return_type args = args_types.keys types = args_types.values # If the exact arg has a pattern, prefer to use that if self.has_key?(args[1]) # look for exact arg self[args[1]] elsif types[1].is_a?(Symbol) # look for type symbol self[types[1]] else # look for TYPE or LONG_TYPE or :cast if types[0] == types[1] self[blueprint.key] else self[:cast] || self[blueprint.long_key] end end end |