Sha256: ce7e2882a66b89124c171e52253be87585f42343a3bb3be526cf94781567a373

Contents?: true

Size: 567 Bytes

Versions: 11

Compression:

Stored size: 567 Bytes

Contents

module Liquid
  class RangeLookup
    def self.parse(start_markup, end_markup)
      start_obj = Expression.parse(start_markup)
      end_obj = Expression.parse(end_markup)
      if start_obj.respond_to?(:evaluate) || end_obj.respond_to?(:evaluate)
        new(start_obj, end_obj)
      else
        start_obj.to_i..end_obj.to_i
      end
    end

    def initialize(start_obj, end_obj)
      @start_obj = start_obj
      @end_obj = end_obj
    end

    def evaluate(context)
      context.evaluate(@start_obj).to_i..context.evaluate(@end_obj).to_i
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
locomotivecms-liquid-4.0.0 lib/liquid/range_lookup.rb
liquid-3.0.6 lib/liquid/range_lookup.rb
liquid-3.0.5 lib/liquid/range_lookup.rb
liquid-3.0.4 lib/liquid/range_lookup.rb
liquid-3.0.3 lib/liquid/range_lookup.rb
liquid-3.0.2 lib/liquid/range_lookup.rb
locomotivecms-liquid-4.0.0.alpha2 lib/liquid/range_lookup.rb
locomotivecms-liquid-4.0.0.alpha1 lib/liquid/range_lookup.rb
locomotivecms-liquid-4.0.0.alpha lib/liquid/range_lookup.rb
liquid-3.0.1 lib/liquid/range_lookup.rb
liquid-3.0.0 lib/liquid/range_lookup.rb