Class: String
Instance Method Summary collapse
- #dir? ⇒ Boolean
- #executables ⇒ Object
- #less ⇒ Object (also: #pager)
- #locate ⇒ Object
- #open_with(meth, *args, &block) ⇒ Object (also: #e)
- #|(meth, *args, &block) ⇒ Object
Methods included from Rush::HeadTail
Instance Method Details
#dir? ⇒ Boolean
9 10 11 |
# File 'lib/rush/string_ext.rb', line 9 def dir? ::Dir.exists? self end |
#executables ⇒ Object
30 31 32 |
# File 'lib/rush/string_ext.rb', line 30 def executables Rush::Path.executables end |
#less ⇒ Object Also known as: pager
4 5 6 |
# File 'lib/rush/string_ext.rb', line 4 def less IO.popen('less -R', 'w') { |f| f.puts self } end |
#locate ⇒ Object
13 14 15 |
# File 'lib/rush/string_ext.rb', line 13 def locate Rush::Dir.new(ENV['HOME']).locate self end |
#open_with(meth, *args, &block) ⇒ Object Also known as: e
17 18 19 20 21 22 23 |
# File 'lib/rush/string_ext.rb', line 17 def open_with(meth, *args, &block) if executables.include? meth.to_s system [meth.to_s, *args, self].join(' ') else raise 'No such executable. Maybe something wrong with PATH?' end end |
#|(meth, *args, &block) ⇒ Object
26 27 28 |
# File 'lib/rush/string_ext.rb', line 26 def |(meth, *args, &block) Open3.capture2(meth, stdin_data: self).first end |