Class: Krakow::Command
- Inherits:
-
Object
- Object
- Krakow::Command
- Includes:
- Utils::Lazy
- Defined in:
- lib/krakow/command.rb,
lib/krakow/command/cls.rb,
lib/krakow/command/fin.rb,
lib/krakow/command/nop.rb,
lib/krakow/command/pub.rb,
lib/krakow/command/rdy.rb,
lib/krakow/command/req.rb,
lib/krakow/command/sub.rb,
lib/krakow/command/auth.rb,
lib/krakow/command/mpub.rb,
lib/krakow/command/touch.rb,
lib/krakow/command/identify.rb
Overview
Messages for sending to remote server
Defined Under Namespace
Classes: Auth, Cls, Fin, Identify, Mpub, Nop, Pub, Rdy, Req, Sub, Touch
Instance Attribute Summary collapse
-
#response ⇒ Krakow::FrameType
Response to command.
Class Method Summary collapse
-
.error ⇒ Array<String>
Allowed ERROR return values.
-
.ok ⇒ Array<String>
Allowed OK return values.
-
.response_for(message) ⇒ Symbol
Response type expected.
Instance Method Summary collapse
-
#error?(response) ⇒ TrueClass, FalseClass
Is response ERROR.
-
#name ⇒ String
Name of command.
-
#ok?(response) ⇒ TrueClass, FalseClass
Is response OK.
-
#to_line(*args) ⇒ String
Convert to line output.
Methods included from Utils::Lazy
Methods included from Utils::Logging
Instance Attribute Details
#response ⇒ Krakow::FrameType
Returns response to command.
58 59 60 |
# File 'lib/krakow/command.rb', line 58 def response @response end |
Class Method Details
.error ⇒ Array<String>
Allowed ERROR return values
35 36 37 |
# File 'lib/krakow/command.rb', line 35 def error [] end |
.ok ⇒ Array<String>
Allowed OK return values
28 29 30 |
# File 'lib/krakow/command.rb', line 28 def ok [] end |
.response_for(message) ⇒ Symbol
Response type expected
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/krakow/command.rb', line 43 def response_for() if(.class.ok.empty?) if(.class.error.empty?) :none else :error_only end else :required end end |
Instance Method Details
#error?(response) ⇒ TrueClass, FalseClass
Is response ERROR
83 84 85 86 |
# File 'lib/krakow/command.rb', line 83 def error?(response) response = response.content if response.is_a?(FrameType) self.class.error.include?(response) end |
#name ⇒ String
Returns name of command.
61 62 63 |
# File 'lib/krakow/command.rb', line 61 def name self.class.name.split('::').last.upcase end |
#ok?(response) ⇒ TrueClass, FalseClass
Is response OK
75 76 77 78 |
# File 'lib/krakow/command.rb', line 75 def ok?(response) response = response.content if response.is_a?(FrameType) self.class.ok.include?(response) end |
#to_line(*args) ⇒ String
Convert to line output
68 69 70 |
# File 'lib/krakow/command.rb', line 68 def to_line(*args) raise NotImplementedError.new 'No line conversion method defined!' end |