Class: Nsqrb::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/nsqrb/command.rb

Direct Known Subclasses

Cls, Fin, Identify, Nop, Pub, Rdy, Req, Sub, Touch

Defined Under Namespace

Classes: Cls, Fin, Identify, Nop, Pub, Rdy, Req, Sub, Touch

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Command

Returns a new instance of Command.



4
5
6
# File 'lib/nsqrb/command.rb', line 4

def initialize(args = {})
  @args = args
end

Instance Method Details

#error?(response) ⇒ Boolean

Is response ERROR

Returns:

  • (Boolean)


19
20
21
22
# File 'lib/nsqrb/command.rb', line 19

def error?(response)
  response = response.content if response.is_a?(FrameType)
  self.class.error.include?(response)
end

#ok?(response) ⇒ Boolean

Is response OK

Returns:

  • (Boolean)


13
14
15
16
# File 'lib/nsqrb/command.rb', line 13

def ok?(response)
  response = response.content if response.is_a?(FrameType)
  self.class.ok.include?(response)
end

#to_lineObject



8
9
10
# File 'lib/nsqrb/command.rb', line 8

def to_line
  "#{command}\n"
end