Class: Luoma::RangeLiteral

Inherits:
Expression show all
Defined in:
lib/luoma/expression.rb,
sig/luoma/expression.rbs

Instance Attribute Summary

Attributes inherited from Expression

#span, #token

Instance Method Summary collapse

Methods inherited from Expression

#scope

Constructor Details

#initialize(token, start, stop) ⇒ RangeLiteral

(t_token, Expression, Expression) -> void

Parameters:



877
878
879
880
881
882
# File 'lib/luoma/expression.rb', line 877

def initialize(token, start, stop)
  super(token)
  @start = start
  @stop = stop
  @span = Luoma.span(start.token, stop.token)
end

Instance Method Details

#children::Array[_Traversable]

() -> Array

Returns:



315
316
317
# File 'sig/luoma/expression.rbs', line 315

def children
  [@start, @stop]
end

#evaluate(context) ⇒ Object

(RenderContext) -> untyped

Parameters:

Returns:

  • (Object)


885
886
887
888
889
# File 'lib/luoma/expression.rb', line 885

def evaluate(context)
  start = context.env.to_i(@start.evaluate(context), context, default: 0)
  stop = context.env.to_i(@stop.evaluate(context), context, default: 0)
  RangeDrop.new(start, stop)
end

#to_s::String

() -> String

Returns:

  • (::String)


896
897
898
# File 'lib/luoma/expression.rb', line 896

def to_s
  "(#{@start}..#{@stop})"
end