Class: Hog::Tuple
- Inherits:
-
Object
- Object
- Hog::Tuple
- Defined in:
- lib/hog/tuple.rb
Constant Summary collapse
- SCHEMAS =
{ :udf => UdfSchema.new, :pig => PigSchema.new, :hive => HiveSchema.new }
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, block) ⇒ Tuple
constructor
A new instance of Tuple.
- #method_missing(meth, *args, &block) ⇒ Object
- #prepare(&block) ⇒ Object
- #process(hsh) ⇒ Object
- #schema(kind = :udf) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, block) ⇒ Tuple
Returns a new instance of Tuple.
17 18 19 20 21 |
# File 'lib/hog/tuple.rb', line 17 def initialize(name, block) @name = name @fields = [] self.instance_eval(&block) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
7 8 9 |
# File 'lib/hog/tuple.rb', line 7 def fields @fields end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/hog/tuple.rb', line 8 def name @name end |
Instance Method Details
#prepare(&block) ⇒ Object
32 33 34 |
# File 'lib/hog/tuple.rb', line 32 def prepare(&block) @prepare = block end |
#process(hsh) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/hog/tuple.rb', line 23 def process(hsh) @prepare.call(hsh) res = [] @fields.each do |f| res << f.get(hsh) end res end |
#schema(kind = :udf) ⇒ Object
40 41 42 |
# File 'lib/hog/tuple.rb', line 40 def schema(kind=:udf) SCHEMAS[kind].schema(self) end |
#to_s ⇒ Object
36 37 38 |
# File 'lib/hog/tuple.rb', line 36 def to_s "(#{@fields.map{|f| f.to_s }.join(',')})" end |