Module: L43Rmap::Functions::Predefined

Extended by:
Evaluator::Evaluations
Defined in:
lib/l43_rmap/functions/predefined.rb,
lib/l43_rmap/functions/predefined/str.rb,
lib/l43_rmap/functions/predefined/shell.rb

Defined Under Namespace

Modules: Shell, Str

Class Method Summary collapse

Methods included from Evaluator::Evaluations

evaluate

Class Method Details

.file_extension(rt, *args) ⇒ Object



31
32
33
34
35
36
37
38
39
40
# File 'lib/l43_rmap/functions/predefined.rb', line 31

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



12
13
14
15
16
17
18
# File 'lib/l43_rmap/functions/predefined.rb', line 12

def if_fn(_rt, cond, true_branch, false_branch=nil)
  if cond
    true_branch
  else
    false_branch
  end
end

.inc(_rt, *args) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/l43_rmap/functions/predefined.rb', line 20

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

.unless_fn(_rt, cond, false_branch, true_branch = nil) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/l43_rmap/functions/predefined.rb', line 42

def unless_fn(_rt, cond, false_branch, true_branch=nil)
  if cond
    true_branch
  else
    false_branch
  end
end