Module: L43Rmap::Functions::Predefined
- Extended by:
- Evaluator::Evaluations
- Defined in:
- lib/l43_rmap/functions/predefined.rb,
lib/l43_rmap/functions/predefined/shell.rb
Defined Under Namespace
Modules: Shell
Class Method Summary collapse
- .file_extension(rt, *args) ⇒ Object
- .if_fn(_rt, cond, true_branch, false_branch = nil) ⇒ Object
- .inc(_rt, *args) ⇒ Object
- .lpad(_rt, subject, filler, length) ⇒ Object
- .match(rt, rgx, subject = nil) ⇒ Object
Methods included from Evaluator::Evaluations
Class Method Details
.file_extension(rt, *args) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/l43_rmap/functions/predefined.rb', line 30 def file_extension(rt, *args) case args in [] File.extname(rt.line)[1..] in [fn] File.extname(fn.to_s)[1..] else raise ArgumentError, "ext needs at most 1 argument" end end |
.if_fn(_rt, cond, true_branch, false_branch = nil) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/l43_rmap/functions/predefined.rb', line 11 def if_fn(_rt, cond, true_branch, false_branch=nil) if cond true_branch else false_branch end end |
.inc(_rt, *args) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/l43_rmap/functions/predefined.rb', line 19 def inc(_rt, *args) case args in [] raise ArgumentError, "inc needs at least 1 argument" if args.empty? in [arg] arg.to_i.succ else args.map(&:to_i).sum end end |
.lpad(_rt, subject, filler, length) ⇒ Object
41 42 43 |
# File 'lib/l43_rmap/functions/predefined.rb', line 41 def lpad(_rt, subject, filler, length) subject.to_s.rjust(length.to_i, filler.to_s) end |
.match(rt, rgx, subject = nil) ⇒ Object
45 46 47 48 49 |
# File 'lib/l43_rmap/functions/predefined.rb', line 45 def match(rt, rgx, subject=nil) subject ||= rt.line r = Regexp.compile(rgx) r.match(subject) end |