Sha256: a18c7f45784e22852050a8f133d6b81402d20adecee267e7abf6bf257d3560a5

Contents?: true

Size: 888 Bytes

Versions: 3

Compression:

Stored size: 888 Bytes

Contents

require 'set_builder/modifier/verb'


module SetBuilder
  module Modifiers
    class NumberModifier < Modifier::Verb
      
      
      
      def self.operators
        {
          :is => [:number],
          :is_less_than => [:number],
          :is_greater_than => [:number],
          :is_between => [:number, :number]
        }
      end
      
      
      
      def build_conditions_for(selector)
        case operator
        when :is
          ["#{selector}=?", format_value]
        when :is_less_than
          ["#{selector}<?", format_value]
        when :is_greater_than
          ["#{selector}>?", format_value]
        when :is_between
          ["#{selector}>=? AND #{selector}<=?", values[0], values[1]]
        end
      end
      
      
      
    private
      
      
      
      def format_value
        values[0]
      end
      
      
      
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
set_builder-1.2.0.beta1 lib/set_builder/modifiers/number_modifier.rb
set_builder-1.1.0 lib/set_builder/modifiers/number_modifier.rb
set_builder-1.0.2 lib/set_builder/modifiers/number_modifier.rb