Module: LSL::ShellLike::Inner

Included in:
LSL::ShellLike
Defined in:
lib/lsl/shell.rb

Instance Method Summary collapse

Instance Method Details

#cc(*args) ⇒ Object



52
53
54
55
# File 'lib/lsl/shell.rb', line 52

def cc(*args)
  puts "cc args #{args.inspect}"
  args.reverse.join("")
end

#cd(d) ⇒ Object



59
60
61
# File 'lib/lsl/shell.rb', line 59

def cd(d)
  Dir.chdir(d)
end

#column(arr, a, b) ⇒ Object



91
92
93
# File 'lib/lsl/shell.rb', line 91

def column(arr,a,b)
  arr.map { |x| x[a.to_i..b.to_i].andand.strip }
end

#crop_top(arr, i) ⇒ Object



88
89
90
# File 'lib/lsl/shell.rb', line 88

def crop_top(arr,i)
  arr[i.to_i..-1]
end

#echo(*args) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/lsl/shell.rb', line 21

def echo(*args)
  #puts args.inspect
  ops = (args.last.kind_of?(Hash) ? args.pop : {})
  str = args.join(" ")
  str = str.upcase if ops.has_key?('upper')
  #puts str
  str
end

#echot(*args) ⇒ Object



29
30
31
32
# File 'lib/lsl/shell.rb', line 29

def echot(*args)
  echo(*args)
  echo(*args)
end

#eval(*args) ⇒ Object



66
67
68
# File 'lib/lsl/shell.rb', line 66

def eval(*args)
  Kernel.eval(args.join(" "))
end

#exit(*args) ⇒ Object



62
63
64
65
# File 'lib/lsl/shell.rb', line 62

def exit(*args)
  puts "Exiting"
  Kernel.exit(*args)
end

#fooObject



41
42
43
# File 'lib/lsl/shell.rb', line 41

def foo
  ["foo"]
end

#get(url) ⇒ Object



75
76
77
78
# File 'lib/lsl/shell.rb', line 75

def get(url)
  require 'open-uri'
  open(url).read
end

#la(*args) ⇒ Object



56
57
58
# File 'lib/lsl/shell.rb', line 56

def la(*args)
  ::File.append("spec/mock_dir/log.txt","LOG #{Time.now} " + args.join(",") + "\n")
end

#longest(*args) ⇒ Object



44
45
46
47
48
# File 'lib/lsl/shell.rb', line 44

def longest(*args)
  res = args.sort_by { |x| x.size }.last
  #puts "Longest: #{res}"
  res
end

#ls(d = ".") ⇒ Object



33
34
35
# File 'lib/lsl/shell.rb', line 33

def ls(d=".")
  ec_array "ls #{d}"
end

#p(*args) ⇒ Object



79
80
81
# File 'lib/lsl/shell.rb', line 79

def p(*args)
  ec "python -c " + args.join(" ")
end

#pf(f) ⇒ Object



36
37
38
39
40
# File 'lib/lsl/shell.rb', line 36

def pf(f)
  str = ::File.read(f)
  $printed << str
  puts str
end

#pipe(*args) ⇒ Object



18
19
20
# File 'lib/lsl/shell.rb', line 18

def pipe(*args)
  args
end

#pm(a, b) ⇒ Object



49
50
51
# File 'lib/lsl/shell.rb', line 49

def pm(a,b)
  puts a.length * b.length
end

#pt(a, b) ⇒ Object



72
73
74
# File 'lib/lsl/shell.rb', line 72

def pt(a,b)
  puts a==b
end

#randObject



69
70
71
# File 'lib/lsl/shell.rb', line 69

def rand
  Kernel.rand()
end

#remove(str, c) ⇒ Object



100
101
102
# File 'lib/lsl/shell.rb', line 100

def remove(str,c)
  str.gsub(c,"").strip
end

#sub(a, b, arg) ⇒ Object



85
86
87
# File 'lib/lsl/shell.rb', line 85

def sub(a,b,arg)
  arg[a.to_i..b.to_i]
end

#sum(*args) ⇒ Object



94
95
96
# File 'lib/lsl/shell.rb', line 94

def sum(*args)
  args.flatten.inject(0.0) { |s,i| s + i.to_f }
end

#sumt(*args) ⇒ Object



97
98
99
# File 'lib/lsl/shell.rb', line 97

def sumt(*args)
  args.flatten.inject { |s,i| s + (i.kind_of?(String) ? i.to_f : i) }
end

#without_left(n, arg) ⇒ Object



82
83
84
# File 'lib/lsl/shell.rb', line 82

def without_left(n,arg)
  arg[n.to_i..-1]
end