Class: Piglet::Relation::Stream
- Inherits:
-
Object
- Object
- Piglet::Relation::Stream
- Includes:
- Relation
- Defined in:
- lib/piglet/relation/stream.rb
Overview
:nodoc:
Instance Attribute Summary
Attributes included from Relation
Instance Method Summary collapse
-
#initialize(source, interpreter, args, options = nil) ⇒ Stream
constructor
A new instance of Stream.
- #schema ⇒ Object
- #to_s ⇒ Object
Methods included from Relation
#[], #alias, #cogroup, #cross, #distinct, #eql?, #field, #filter, #foreach, #group, #hash, #join, #limit, #method_missing, #nested_foreach, #next_field_alias, #order, #sample, #split, #stream, #union
Constructor Details
#initialize(source, interpreter, args, options = nil) ⇒ Stream
Returns a new instance of Stream.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/piglet/relation/stream.rb', line 8 def initialize(source, interpreter, args, =nil) @interpreter = interpreter ||= {} @sources = [source] args.each do |arg| @sources << arg if arg.is_a?(Relation) || arg.is_a?(Array) end @command_reference = (args - @sources).first @sources = @sources.flatten @command = [:command] @schema = [:schema] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Piglet::Relation::Relation
Instance Method Details
#schema ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/piglet/relation/stream.rb', line 21 def schema if @schema Piglet::Schema::Tuple.parse(@schema) else nil end end |
#to_s ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/piglet/relation/stream.rb', line 29 def to_s source_str = @sources.map { |s| s.alias }.join(', ') str = "STREAM #{source_str} THROUGH" if @command_reference str << " #{@command_reference}" else str << " `#{@command}`" end if @schema str << " AS #{schema}" end str end |