Class: Fabulator::Expr::RangeExpr

Inherits:
BinExpr
  • Object
show all
Defined in:
lib/fabulator/expr/bin_expr.rb

Instance Method Summary collapse

Methods inherited from BinExpr

#initialize, #run

Constructor Details

This class inherits a constructor from Fabulator::Expr::BinExpr

Instance Method Details

#calculate(a, b) ⇒ Object



187
188
189
190
191
192
193
194
195
# File 'lib/fabulator/expr/bin_expr.rb', line 187

def calculate(a,b)
  return nil if a.nil? || b.nil?
  if a < b
    r = (a.to_i .. b.to_i).to_a
  else
    r = (b.to_i .. a.to_i).to_a.reverse
  end
  return r
end

#expr_type(context) ⇒ Object



179
180
181
# File 'lib/fabulator/expr/bin_expr.rb', line 179

def expr_type(context)
  [ FAB_NS, 'numeric' ]
end

#opObject



175
176
177
# File 'lib/fabulator/expr/bin_expr.rb', line 175

def op
  :range
end

#result_type(t) ⇒ Object



183
184
185
# File 'lib/fabulator/expr/bin_expr.rb', line 183

def result_type(t)
  [ FAB_NS, 'numeric' ]
end