Module: LiveConsole::IOMethods::IOMethod

Included in:
SocketIO, UnixSocket
Defined in:
lib/live_console/io_methods.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(other) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/live_console/io_methods.rb', line 35

def self.included(other)
  other.instance_eval {
    readers = [:opts]
    attr_accessor *readers
    private *readers.map { |r| (r.to_s + '=').to_sym }
      other::RequiredOpts.each { |opt|
      define_method(opt) { opts[opt] }
    }
  }
end

Instance Method Details

#initialize(opts) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/live_console/io_methods.rb', line 23

def initialize(opts)
  self.opts = self.class::DefaultOpts.merge opts
  unless missing_opts.empty?
    raise ArgumentError, "Missing opts for " \
      "#{self.class.name}:  #{missing_opts.inspect}"
  end
end

#missing_optsObject



31
32
33
# File 'lib/live_console/io_methods.rb', line 31

def missing_opts
  self.class::RequiredOpts - opts.keys
end