Class: Bmg::Operator::Undress

Inherits:
Object
  • Object
show all
Includes:
Unary
Defined in:
lib/bmg/operator/undress.rb

Overview

Undress operator.

Transform all values to keep only integer, strings & booleans

Constant Summary collapse

DEFAULT_OPTIONS =
{}

Instance Attribute Summary

Attributes included from Bmg::Operator

#type

Instance Method Summary collapse

Methods included from Unary

#bind

Methods included from Bmg::Operator

#inspect, #to_s

Methods included from Relation

#_count, #bind, #count, #debug, #delete, #empty?, #insert, new, #one, #one_or_nil, #to_csv, #to_json, #to_text, #to_xlsx, #type, #update, #visit, #with_type, #with_type_attrlist, #with_typecheck, #without_typecheck, #y_by_x, #ys_by_x

Methods included from Factory

#csv, #empty, #excel, #excel_file, #generate, #in_memory, #json, #json_file, #mutable, #text_file, #yaml, #yaml_file

Methods included from Algebra

#allbut, #autosummarize, #autowrap, #constants, #extend, #group, #image, #join, #left_join, #matching, #materialize, #minus, #not_matching, #page, #project, #rename, #restrict, #spied, #summarize, #transform, #ungroup, #union, #unspied, #unwrap

Methods included from Algebra::Shortcuts

#cross_product, #exclude, #image, #images, #join, #left_join, #matching, #not_matching, #prefix, #rxmatch, #suffix, #ungroup, #unwrap, #where

Constructor Details

#initialize(type, operand, options = {}) ⇒ Undress

Returns a new instance of Undress.



13
14
15
16
17
# File 'lib/bmg/operator/undress.rb', line 13

def initialize(type, operand, options = {})
  @type = type
  @operand = operand
  @options = DEFAULT_OPTIONS.merge(options)
end

Instance Method Details

#eachObject



25
26
27
28
29
30
31
# File 'lib/bmg/operator/undress.rb', line 25

def each
  return to_enum unless block_given?

  @operand.each do |tuple|
    yield undress(tuple)
  end
end

#to_astObject



33
34
35
# File 'lib/bmg/operator/undress.rb', line 33

def to_ast
  [ :transform, operand.to_ast, transformation.dup ]
end