class KRPC::Streaming::Stream
Attributes
args[R]
id[R]
kwargs[R]
manager[R]
method[R]
rate[R]
return_type[R]
value[W]
Public Class Methods
new(manager, id, return_type, value, method, *args, **kwargs)
click to toggle source
# File lib/krpc/streaming.rb, line 86 def initialize(manager, id, return_type, value, method, *args, **kwargs) @manager = manager @id = id @return_type, @value = return_type, value @method, @args, @kwargs = method, args, kwargs @active = true @rate = 0 end
Public Instance Methods
active?()
click to toggle source
Check if stream is active (i.e. not removed).
# File lib/krpc/streaming.rb, line 109 def active?; @active end
coderay(x)
click to toggle source
# File lib/krpc/streaming.rb, line 125 def coderay(x) require 'coderay' if x.is_a?(Array) then "[" + x.map{|e| e.is_a?(Gen::ClassBase) ? e.inspect : coderay(e.inspect)}.join(", ") + "]" elsif x.is_a?(Hash) then "{" + x.map{|k,v| coderay(k.inspect) + "=>" + (v.is_a?(Gen::ClassBase) ? v.inspect : coderay(v.inspect))}.join(", ") + "}" else CodeRay.scan(x, :ruby).term end rescue Exception x.inspect end
get()
click to toggle source
Get the current stream value. Has alias method value
.
# File lib/krpc/streaming.rb, line 96 def get raise @value if @value.is_a?(Exception) @value end
Also aliased as: value
inspect()
click to toggle source
# File lib/krpc/streaming.rb, line 124 def inspect def coderay(x) require 'coderay' if x.is_a?(Array) then "[" + x.map{|e| e.is_a?(Gen::ClassBase) ? e.inspect : coderay(e.inspect)}.join(", ") + "]" elsif x.is_a?(Hash) then "{" + x.map{|k,v| coderay(k.inspect) + "=>" + (v.is_a?(Gen::ClassBase) ? v.inspect : coderay(v.inspect))}.join(", ") + "}" else CodeRay.scan(x, :ruby).term end rescue Exception x.inspect end "#<#{self.class}".green + " @id" + "=".green + id.to_s.bold.blue + " @active" + "=".green + @active.to_s.bold.light_cyan + " @rate" + "=".green + rate.to_s.bold.blue + "\n\t@method" + "=".green + method.inspect.green + (args.empty? ? "" : "\n\t@args" + "=".green + coderay(args)) + (kwargs.empty? ? "" : "\n\t@kwargs" + "=".green + coderay(kwargs)) + "\n\treturn_ruby_type" + "=".green + coderay(return_type.ruby_type) + ">".green end
mark_as_inactive()
click to toggle source
Mark stream as inactive. WARNING: This method does not remove the stream. To remove the stream call Stream#remove
instead.
# File lib/krpc/streaming.rb, line 113 def mark_as_inactive; @active = false end
rate=(rate)
click to toggle source
# File lib/krpc/streaming.rb, line 115 def rate=(rate) manager.client.core.set_stream_rate(id, rate) @rate = rate end
remove()
click to toggle source
Remove stream. Has alias method close
.
# File lib/krpc/streaming.rb, line 103 def remove manager.remove_stream self end
Also aliased as: close
to_s()
click to toggle source
# File lib/krpc/streaming.rb, line 120 def to_s inspect.gsub(/\n|\t/," ").squeeze(" ").uncolorize end