Class: Pacer::Filter::PropertyFilter::EdgeFilters

Inherits:
Filters
  • Object
show all
Defined in:
lib/pacer/filter/property_filter/edge_filters.rb

Constant Summary

Constants inherited from Filters

Filters::NodeVisitor

Instance Attribute Summary collapse

Attributes inherited from Filters

#best_index_value, #blocks, #choose_best_index, #extensions, #graph, #indices, #properties, #route_modules, #search_manual_indices, #wrapper

Instance Method Summary collapse

Methods inherited from Filters

#combine_sets, #property_keys, #remove_property_keys, #to_predicate, #use_lookup!

Constructor Details

#initialize(graph, filters) ⇒ EdgeFilters

Returns a new instance of EdgeFilters.



13
14
15
16
17
18
# File 'lib/pacer/filter/property_filter/edge_filters.rb', line 13

def initialize(graph, filters)
  @best_index = nil
  self.labels = []
  self.non_ext_labels = []
  super
end

Instance Attribute Details

#labelsObject

Returns the value of attribute labels.



5
6
7
# File 'lib/pacer/filter/property_filter/edge_filters.rb', line 5

def labels
  @labels
end

Instance Method Details

#add_filter(filter, extension) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/pacer/filter/property_filter/edge_filters.rb', line 20

def add_filter(filter, extension)
  case filter
  when String, Symbol
    reset_properties
    self.non_ext_labels << filter
    self.labels << filter.to_s
  else
    super
  end
end

#any?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/pacer/filter/property_filter/edge_filters.rb', line 43

def any?
  labels.any? or super
end

#best_index(route) ⇒ Object



59
60
61
62
63
64
65
# File 'lib/pacer/filter/property_filter/edge_filters.rb', line 59

def best_index(route)
  index, key, value = find_best_index(route)
  if key == 'label'
    labels.delete value
  end
  super
end

#build_pipeline(route, start_pipe = nil, pipe = nil) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/pacer/filter/property_filter/edge_filters.rb', line 31

def build_pipeline(route, start_pipe = nil, pipe = nil)
  pipe ||= start_pipe
  if labels.any?
    label_pipe = Pacer::Pipes::LabelCollectionFilterPipe.new labels.map(&:to_s)
    label_pipe.set_starts pipe if pipe
    Pacer.debug_pipes << { :name => labels.inspect, :start => pipe, :end => block_pipe } if Pacer.debug_pipes
    pipe = label_pipe
    start_pipe ||= pipe
  end
  super(route, start_pipe, pipe)
end

#extensions_only?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/pacer/filter/property_filter/edge_filters.rb', line 47

def extensions_only?
  labels.empty? and super
end

#to_sObject



51
52
53
54
55
56
57
# File 'lib/pacer/filter/property_filter/edge_filters.rb', line 51

def to_s
  if labels.any?
    [labels.map { |l| l.to_sym.inspect }.join(', '), super].reject { |s| s == '' }.join ', '
  else
    super
  end
end