class Rmate::Command
Public Class Methods
new(name)
click to toggle source
# File lib/rmate.rb, line 78 def initialize(name) @command = name @variables = {} @data = nil @size = nil end
Public Instance Methods
[]=(name, value)
click to toggle source
# File lib/rmate.rb, line 85 def []=(name, value) @variables[name] = value end
read_file(path)
click to toggle source
# File lib/rmate.rb, line 89 def read_file(path) @size = File.size(path) @data = File.open(path, "rb") { |io| io.read(@size) } end
read_stdin()
click to toggle source
# File lib/rmate.rb, line 94 def read_stdin @data = $stdin.read @size = @data.bytesize end
send(socket)
click to toggle source
# File lib/rmate.rb, line 99 def send(socket) socket.puts @command @variables.each_pair do |name, value| value = 'yes' if value === true socket.puts "#{name}: #{value}" end if @data socket.puts "data: #{@size}" socket.puts @data end socket.puts end