Class: Arrow::Slicer::ColumnCondition

Inherits:
Condition
  • Object
show all
Defined in:
lib/arrow/slicer.rb

Instance Method Summary collapse

Methods inherited from Condition

#&, #^, #|

Constructor Details

#initialize(column) ⇒ ColumnCondition

Returns a new instance of ColumnCondition.



110
111
112
# File 'lib/arrow/slicer.rb', line 110

def initialize(column)
  @column = column
end

Instance Method Details

#!=(value) ⇒ Object



134
135
136
# File 'lib/arrow/slicer.rb', line 134

def !=(value)
  NotEqualCondition.new(@column, value)
end

#!@Object



118
119
120
# File 'lib/arrow/slicer.rb', line 118

def !@
  NotColumnCondition.new(@column)
end

#<(value) ⇒ Object



138
139
140
# File 'lib/arrow/slicer.rb', line 138

def <(value)
  LessCondition.new(@column, value)
end

#<=(value) ⇒ Object



142
143
144
# File 'lib/arrow/slicer.rb', line 142

def <=(value)
  LessEqualCondition.new(@column, value)
end

#==(value) ⇒ Object



130
131
132
# File 'lib/arrow/slicer.rb', line 130

def ==(value)
  EqualCondition.new(@column, value)
end

#>(value) ⇒ Object



146
147
148
# File 'lib/arrow/slicer.rb', line 146

def >(value)
  GreaterCondition.new(@column, value)
end

#>=(value) ⇒ Object



150
151
152
# File 'lib/arrow/slicer.rb', line 150

def >=(value)
  GreaterEqualCondition.new(@column, value)
end

#end_with?(substring, ignore_case: false) ⇒ Boolean

Returns:

  • (Boolean)


166
167
168
169
# File 'lib/arrow/slicer.rb', line 166

def end_with?(substring, ignore_case: false)
  MatchSubstringFamilyCondition.new("ends_with",
                                    @column, substring, ignore_case)
end

#evaluateObject



114
115
116
# File 'lib/arrow/slicer.rb', line 114

def evaluate
  Helper.ensure_boolean(@column)
end

#in?(values) ⇒ Boolean

Returns:

  • (Boolean)


154
155
156
# File 'lib/arrow/slicer.rb', line 154

def in?(values)
  InCondition.new(@column, values)
end

#match_like?(pattern, ignore_case: false) ⇒ Boolean

Returns:

  • (Boolean)


171
172
173
174
# File 'lib/arrow/slicer.rb', line 171

def match_like?(pattern, ignore_case: false)
  MatchSubstringFamilyCondition.new("match_like",
                                    @column, pattern, ignore_case)
end

#match_substring?(pattern, ignore_case: nil) ⇒ Boolean

Returns:

  • (Boolean)


176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/arrow/slicer.rb', line 176

def match_substring?(pattern, ignore_case: nil)
  case pattern
  when String
    ignore_case = false if ignore_case.nil?
    MatchSubstringFamilyCondition.new("match_substring",
                                      @column, pattern, ignore_case)
  when Regexp
    ignore_case = pattern.casefold? if ignore_case.nil?
    MatchSubstringFamilyCondition.new("match_substring_regex",
                                      @column,
                                      pattern.source,
                                      ignore_case)
  else
    message =
       "pattern must be either String or Regexp: #{pattern.inspect}"
    raise ArgumentError, message
  end
end

#null?Boolean

Returns:

  • (Boolean)


122
123
124
# File 'lib/arrow/slicer.rb', line 122

def null?
  self == nil
end

#reject(&block) ⇒ Object



162
163
164
# File 'lib/arrow/slicer.rb', line 162

def reject(&block)
  RejectCondition.new(@column, block)
end

#select(&block) ⇒ Object



158
159
160
# File 'lib/arrow/slicer.rb', line 158

def select(&block)
  SelectCondition.new(@column, block)
end

#start_with?(substring, ignore_case: false) ⇒ Boolean

Returns:

  • (Boolean)


195
196
197
198
# File 'lib/arrow/slicer.rb', line 195

def start_with?(substring, ignore_case: false)
  MatchSubstringFamilyCondition.new("starts_with",
                                    @column, substring, ignore_case)
end

#valid?Boolean

Returns:

  • (Boolean)


126
127
128
# File 'lib/arrow/slicer.rb', line 126

def valid?
  self != nil
end