Class: String

Inherits:
Object
  • Object
show all
Includes:
Rush::HeadTail
Defined in:
lib/rush/string_ext.rb

Instance Method Summary collapse

Methods included from Rush::HeadTail

#head, #tail

Instance Method Details

#dir?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/rush/string_ext.rb', line 9

def dir?
  ::Dir.exists? self
end

#executablesObject



30
31
32
# File 'lib/rush/string_ext.rb', line 30

def executables
  Rush::Path.executables
end

#lessObject 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

#locateObject



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