Class: ConceptQL::Converter::Operator
- Inherits:
-
Object
- Object
- ConceptQL::Converter::Operator
- Defined in:
- lib/conceptql/converter.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
- #args ⇒ Object
- #converted_options ⇒ Object
-
#initialize(type, *values) ⇒ Operator
constructor
A new instance of Operator.
- #to_list_syntax ⇒ Object
- #upstreams ⇒ Object
Constructor Details
#initialize(type, *values) ⇒ Operator
Returns a new instance of Operator.
14 15 16 17 18 |
# File 'lib/conceptql/converter.rb', line 14 def initialize(type, *values) @type, @values = type, values.flatten @options = @values..deep_rekey @values = @values end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
13 14 15 |
# File 'lib/conceptql/converter.rb', line 13 def @options end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
13 14 15 |
# File 'lib/conceptql/converter.rb', line 13 def type @type end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
13 14 15 |
# File 'lib/conceptql/converter.rb', line 13 def values @values end |
Instance Method Details
#args ⇒ Object
20 21 22 |
# File 'lib/conceptql/converter.rb', line 20 def args values.select { |s| !s.is_a?(Operator) } end |
#converted_options ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/conceptql/converter.rb', line 28 def .update_values do |value| if value.is_a?(Operator) value.to_list_syntax else value end end end |
#to_list_syntax ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/conceptql/converter.rb', line 38 def to_list_syntax stmt = [type] stmt += args unless args.empty? stmt += upstreams.map(&:to_list_syntax) unless upstreams.empty? stmt << unless .empty? stmt end |
#upstreams ⇒ Object
24 25 26 |
# File 'lib/conceptql/converter.rb', line 24 def upstreams values.select { |s| s.is_a?(Operator) } end |