Class: LabelFilter

Inherits:
Array
  • Object
show all
Defined in:
app/models/label_filter.rb

Instance Method Summary collapse

Constructor Details

#initialize(filter_query) ⇒ LabelFilter

Returns a new instance of LabelFilter.



2
3
4
5
# File 'app/models/label_filter.rb', line 2

def initialize(filter_query)
  label_ids = (filter_query || "").split('-').map{|id| id.to_i}
  super(label_ids)
end

Instance Method Details

#to_conditionObject



6
7
8
# File 'app/models/label_filter.rb', line 6

def to_condition
  "labelings.label_id IN(#{self.join(',')})"
end

#to_query_exclude(id) ⇒ Object



12
13
14
# File 'app/models/label_filter.rb', line 12

def to_query_exclude(id)
  self.reject{|i| i == id}.join('-')
end

#to_query_include(id) ⇒ Object



9
10
11
# File 'app/models/label_filter.rb', line 9

def to_query_include(id)
  (self + [id]).join('-')
end