Module: CSVPlusPlus::Entities::Builtins
- Extended by:
- ASTBuilder, T::Sig
- Defined in:
- lib/csv_plus_plus/entities/builtins.rb
Overview
Provides RuntimeValues for builtin functions and variables
Constant Summary collapse
- VARIABLES =
::T.let( { # The number (integer) of the current cell. Starts at 1 cellnum: runtime_value(->(p, _args) { number(p.cell_index + 1) }), # A reference to the current cell cellref: runtime_value(->(p, _args) { cell_ref(p.row_index, p.cell_index) }), # A reference to the row above rowabove: runtime_value(->(p, _args) { cell_ref([0, (p.row_index - 1)].max) }), # A reference to the row below rowbelow: runtime_value(->(p, _args) { cell_ref(p.row_index + 1) }), # The number (integer) of the current row. Starts at 1 rownum: runtime_value(->(p, _args) { number(p.rownum) }), # A reference to the current row rowref: runtime_value(->(p, _args) { cell_ref(p.row_index) }) }.freeze, ::T::Hash[::Symbol, ::CSVPlusPlus::Entities::RuntimeValue] )
- FUNCTIONS =
TODO: A reference to a cell in a given row? TODO: check types of the args and throw a more friendly error?
::T.let( { # A reference to a cell above the current row cellabove: runtime_value(->(p, args) { cell_ref([0, (p.row_index - 1)].max, args[0].a1_ref.cell_index) }), # A reference to a cell in the current row celladjacent: runtime_value(->(p, args) { cell_ref(p.row_index, args[0].a1_ref.cell_index) }), # A reference to a cell below the current row cellbelow: runtime_value(->(p, args) { cell_ref(p.row_index + 1, args[0].a1_ref.cell_index) }) }.freeze, ::T::Hash[::Symbol, ::CSVPlusPlus::Entities::RuntimeValue] )
Class Method Summary collapse
-
.builtin_function?(fn_id) ⇒ T::Boolean
Is
fn_id
a builtin function?. -
.builtin_variable?(var_id) ⇒ Boolean
Is
var_id
a builtin variable?.
Methods included from ASTBuilder
method_missing, respond_to_missing?
Class Method Details
.builtin_function?(fn_id) ⇒ T::Boolean
Is fn_id
a builtin function?
59 60 61 |
# File 'lib/csv_plus_plus/entities/builtins.rb', line 59 def self.builtin_function?(fn_id) ::CSVPlusPlus::Entities::Builtins::FUNCTIONS.key?(fn_id) end |
.builtin_variable?(var_id) ⇒ Boolean
Is var_id
a builtin variable?
69 70 71 |
# File 'lib/csv_plus_plus/entities/builtins.rb', line 69 def self.builtin_variable?(var_id) ::CSVPlusPlus::Entities::Builtins::VARIABLES.key?(var_id) end |