Module: CTioga2::Data::Filters

Defined in:
lib/ctioga2/data/filters.rb

Overview

A series of commands that can be used as “filters”, as they act upon the last Dataset pushed unto the stack.

Constant Summary collapse

FiltersGroup =
CmdGroup.new('filter', "Filters",
"The commands in this group act upon the last 
dataset pushed unto the data stack: they can be viewed as filters.", 
101)
SortOperation =
Cmd.new("sort-last", nil, "--sort-last", 
          [], {}) do |plotmaker, opts|
  plotmaker.data_stack.last.sort!
end
SortFilter =
Cmd.new("sort", nil, "--sort", 
          [], {}) do |plotmaker, opts|
  plotmaker.data_stack.add_to_dataset_hook('sort-last()')
end
TrimOperation =
Cmd.new("trim-last", nil, "--trim-last", 
          [CmdArg.new('integer')], {}) do |plotmaker, number, opts|
  plotmaker.data_stack.last.trim!(number)
end
TrimFilter =
Cmd.new("trim", nil, "--trim", 
          [CmdArg.new('integer')], {}) do |plotmaker, number, opts|
  ## @todo There should be a way to add commands in a type-safe
  ## way, without having to convert to string first.
  plotmaker.data_stack.add_to_dataset_hook("trim-last(#{number})")
end
CherryPickOperation =
Cmd.new("cherry-pick-last", nil, "--cherry-pick-last", 
          [CmdArg.new('text')], {}) do |plotmaker, formula|
  plotmaker.data_stack.last.select_formula!(formula)
end
CherryPickFilter =
Cmd.new("cherry-pick", nil, "--cherry-pick", 
          [CmdArg.new('text')], {}) do |plotmaker, formula|
  plotmaker.data_stack.add_to_dataset_hook("cherry-pick-last(#{formula})")
end
AverageDupOperation =
Cmd.new("avg-dup-last", nil, "--avg-dup-last", 
          [], {}) do |plotmaker|
  plotmaker.data_stack.last.average_duplicates!
end
AverageDupFilter =
Cmd.new("avg-dup", nil, "--avg-dup", 
          [], {}) do |plotmaker, formula|
  plotmaker.data_stack.add_to_dataset_hook("avg-dup-last()")
end
SmoothOperation =
Cmd.new("smooth-last", nil, "--smooth-last", 
          [CmdArg.new('integer')], {}) do |plotmaker, number|
  plotmaker.data_stack.last.naive_smooth!(number)
end