class GunTest::Shot

Public Class Methods

new() click to toggle source
# File lib/gun_test/shot.rb, line 7
def initialize
  @bullet = nil
  @target = nil
end

Public Instance Methods

bang!(gun) click to toggle source
# File lib/gun_test/shot.rb, line 22
def bang!(gun)
  cmd = (gun[0] == '/' ? '' : './') + gun

  IO.popen(cmd, "r+") do |io|
    io.puts @bullet
    io.close_write

    @target == io.gets(nil)
  end
end
bullet(bullet = nil) { || ... } click to toggle source
# File lib/gun_test/shot.rb, line 12
def bullet(bullet = nil)
  @bullet = bullet
  @bullet ||= yield if block_given?
end
target(target = nil) { || ... } click to toggle source
# File lib/gun_test/shot.rb, line 17
def target(target = nil)
  @target = target
  @target ||= yield if block_given?
end