Class: Krakow::Command
- Inherits:
-
Object
- Object
- Krakow::Command
- Includes:
- Utils::Lazy
- Defined in:
- lib/krakow/command.rb,
lib/krakow/command/sub.rb,
lib/krakow/command/nop.rb,
lib/krakow/command/rdy.rb,
lib/krakow/command/pub.rb,
lib/krakow/command/fin.rb,
lib/krakow/command/req.rb,
lib/krakow/command/cls.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: Cls, Fin, Identify, Mpub, Nop, Pub, Rdy, Req, Sub, Touch
Instance Attribute Summary (collapse)
-
- (Krakow::FrameType) response
Response to command.
Class Method Summary (collapse)
-
+ (Array<String>) error
Allowed ERROR return values.
-
+ (Array<String>) ok
Allowed OK return values.
-
+ (Symbol) response_for(message)
Response type expected.
Instance Method Summary (collapse)
-
- (TrueClass, FalseClass) error?(response)
Is response ERROR.
-
- (Logger?) log(*args)
included
from Utils::Logging
Log message.
-
- (String) name
Name of command.
-
- (TrueClass, FalseClass) ok?(response)
Is response OK.
-
- (String) to_line(*args)
Convert to line output.
Instance Attribute Details
- (Krakow::FrameType) response
Returns response to command
46 47 48 |
# File 'lib/krakow/command.rb', line 46 def response @response end |
Class Method Details
+ (Array<String>) error
Allowed ERROR return values
23 24 25 |
# File 'lib/krakow/command.rb', line 23 def error [] end |
+ (Array<String>) ok
Allowed OK return values
16 17 18 |
# File 'lib/krakow/command.rb', line 16 def ok [] end |
+ (Symbol) response_for(message)
Response type expected
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/krakow/command.rb', line 31 def response_for() if(.class.ok.empty?) if(.class.error.empty?) :none else :error_only end else :required end end |
Instance Method Details
- (TrueClass, FalseClass) error?(response)
Is response ERROR
71 72 73 74 |
# File 'lib/krakow/command.rb', line 71 def error?(response) response = response.content if response.is_a?(FrameType) self.class.error.include?(response) end |
- (Logger?) log(*args) Originally defined in module Utils::Logging
Log message
- (String) name
Returns name of command
49 50 51 |
# File 'lib/krakow/command.rb', line 49 def name self.class.name.split('::').last.upcase end |
- (TrueClass, FalseClass) ok?(response)
Is response OK
63 64 65 66 |
# File 'lib/krakow/command.rb', line 63 def ok?(response) response = response.content if response.is_a?(FrameType) self.class.ok.include?(response) end |
- (String) to_line(*args)
Convert to line output
56 57 58 |
# File 'lib/krakow/command.rb', line 56 def to_line(*args) raise NotImplementedError.new 'No line conversion method defined!' end |