Module: L43Rmap::Functions
- Defined in:
- lib/l43_rmap/functions.rb,
lib/l43_rmap/functions/predefined.rb,
lib/l43_rmap/functions/predefined/shell.rb
Defined Under Namespace
Modules: Predefined
Constant Summary collapse
- DefinedFields =
{ # Linenumber "n" => Function.new("lnb") { |rt| rt.lnb }, # Timestamps "m" => Function.new("timestamp m") { |rt| rt.runtime.(36) }, "ms" => Function.new("timestamp ms") { |rt| rt.runtime.(36, mult: 1) }, "M" => Function.new("timestamp M") { |rt| rt.runtime.(36, now: rt.time) }, "Ms" => Function.new("timestamp Ms") { |rt| rt.runtime.(36, now: rt.time, mult: 1) }, "t" => Function.new("timestamp X") { |rt| rt.runtime.(10) }, "ts" => Function.new("timestamp Xs") { |rt| rt.runtime.(10, mult: 1) }, "T" => Function.new("timestamp X") { |rt| rt.runtime.(10, now: rt.time) }, "Ts" => Function.new("timestamp Xs") { |rt| rt.runtime.(10, now: rt.time, mult: 1) }, "x" => Function.new("timestamp X") { |rt| rt.runtime.(16) }, "xs" => Function.new("timestamp Xs") { |rt| rt.runtime.(16, mult: 1) }, "X" => Function.new("timestamp X") { |rt| rt.runtime.(16, now: rt.time) }, "Xs" => Function.new("timestamp Xs") { |rt| rt.runtime.(16, now: rt.time, mult: 1) }, # Randomness "rd" => Function.new("random rd") { |rt| rt.runtime.random_rd }, "rx" => Function.new("random rx") { |rt| rt.runtime.random_hex }, "Rd" => Function.new("random Rd") { |_rt| format "%04d", SecureRandom.random_number(10_000) }, "Rx" => Function.new("random Rx") { |_rt| SecureRandom.hex }, }
- DefinedFunctions =
Names only available inside of S-Expressions
{ "ext" => Function.new("ext") { |*args| Predefined.file_extension(*args) }, "inc" => Function.new("inc") { |*args| Predefined.inc(*args) }, "if" => Function.new("if") { |*args| Predefined.if_fn(*args) }, "lpad" => Function.new("lpad") { |*args| Predefined.lpad(*args) }, "m" => Function.new("match") { |*args| Predefined.match(*args) }, "se" => Function.new("se") { |*args| Predefined::Shell.se(*args) }, }
- AllFunctions =
DefinedFields.merge(DefinedFunctions)
Class Method Summary collapse
Class Method Details
.get_field(name) ⇒ Object
51 52 53 |
# File 'lib/l43_rmap/functions.rb', line 51 def get_field(name) DefinedFields.fetch(name) end |
.get_function(name) ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/l43_rmap/functions.rb', line 55 def get_function(name) AllFunctions.fetch(name) do Function.new("fallback to #{name}") do |rt, rcv, *args| rcv.send(name, *args) rescue NoMethodError rcv.to_i.send(name, *args) end end end |