Class: Liquid::RangeLookup
- Inherits:
-
Object
- Object
- Liquid::RangeLookup
- Defined in:
- lib/liquid/range_lookup.rb
Class Method Summary collapse
Instance Method Summary collapse
- #evaluate(context) ⇒ Object
-
#initialize(start_obj, end_obj) ⇒ RangeLookup
constructor
A new instance of RangeLookup.
Constructor Details
#initialize(start_obj, end_obj) ⇒ RangeLookup
Returns a new instance of RangeLookup.
13 14 15 16 |
# File 'lib/liquid/range_lookup.rb', line 13 def initialize(start_obj, end_obj) @start_obj = start_obj @end_obj = end_obj end |
Class Method Details
.parse(start_markup, end_markup) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/liquid/range_lookup.rb', line 3 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 |
Instance Method Details
#evaluate(context) ⇒ Object
18 19 20 21 22 |
# File 'lib/liquid/range_lookup.rb', line 18 def evaluate(context) start_int = to_integer(context.evaluate(@start_obj)) end_int = to_integer(context.evaluate(@end_obj)) start_int..end_int end |