Module: Warden::Protocol
- Defined in:
- lib/warden/protocol/pb.rb,
lib/warden/protocol/pb.rb,
lib/warden/protocol/pb.rb,
lib/warden/protocol/pb.rb,
lib/warden/protocol/pb.rb,
lib/warden/protocol/pb.rb,
lib/warden/protocol/pb.rb,
lib/warden/protocol/pb.rb,
lib/warden/protocol/pb.rb,
lib/warden/protocol/pb.rb,
lib/warden/protocol/pb.rb,
lib/warden/protocol/pb.rb,
lib/warden/protocol/pb.rb,
lib/warden/protocol/pb.rb,
lib/warden/protocol/pb.rb,
lib/warden/protocol/pb.rb,
lib/warden/protocol/pb.rb,
lib/warden/protocol/pb.rb,
lib/warden/protocol/pb.rb,
lib/warden/protocol/pb.rb,
lib/warden/protocol/pb.rb,
lib/warden/protocol/pb.rb,
lib/warden/protocol/base.rb,
lib/warden/protocol/buffer.rb,
lib/warden/protocol/message.rb,
lib/warden/protocol/version.rb
Defined Under Namespace
Modules: BaseMessage, BaseRequest, BaseResponse
Classes: Buffer, CopyInRequest, CopyInResponse, CopyOutRequest, CopyOutResponse, CreateRequest, CreateResponse, DestroyRequest, DestroyResponse, EchoRequest, EchoResponse, ErrorResponse, InfoRequest, InfoResponse, LimitBandwidthRequest, LimitBandwidthResponse, LimitCpuRequest, LimitCpuResponse, LimitDiskRequest, LimitDiskResponse, LimitMemoryRequest, LimitMemoryResponse, LinkRequest, LinkResponse, ListRequest, ListResponse, Message, NetInRequest, NetInResponse, NetOutRequest, NetOutResponse, PingRequest, PingResponse, ProtocolError, ResourceLimits, RunRequest, RunResponse, SpawnRequest, SpawnResponse, StopRequest, StopResponse, StreamRequest, StreamResponse
Constant Summary
collapse
- TypeConverter =
{
:bool => lambda do |arg|
return true if arg.downcase == "true"
return false if arg.downcase == "false"
raise ArgumentError, "Expected 'true' or 'false', but received: '#{arg}'."
end,
:int32 => lambda { |arg| Integer(arg) },
:uint32 => lambda { |arg| Integer(arg) },
:sint32 => lambda { |arg| Integer(arg) },
:int64 => lambda { |arg| Integer(arg) },
:uint64 => lambda { |arg| Integer(arg) },
:fixed32 => lambda { |arg| Float(arg) },
:sfixed32 => lambda { |arg| Float(arg) },
:float => lambda { |arg| Float(arg) },
:fixed64 => lambda { |arg| Float(arg) },
:sfixed64 => lambda { |arg| Float(arg) },
:double => lambda { |arg| Float(arg) },
:string => lambda { |arg| String(arg) },
}
- VERSION =
"0.1.4"
Class Method Summary
collapse
Class Method Details
.protocol_type_to_str(protocol_type) ⇒ Object
55
56
57
58
59
60
61
62
63
|
# File 'lib/warden/protocol/base.rb', line 55
def self.protocol_type_to_str(protocol_type)
if protocol_type.class == Module
return "#{protocol_type.constants.sort.join(", ")}"
elsif protocol_type.is_a?(Symbol)
return "#{protocol_type.to_s}"
end
return nil
end
|
.to_ruby_type(str, protocol_type) ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/warden/protocol/base.rb', line 65
def self.to_ruby_type(str, protocol_type)
converter = Warden::Protocol::TypeConverter[protocol_type]
return converter.call(str) if converter
error_msg = nil
if protocol_type.class == Module
return protocol_type.const_get(str) if protocol_type.const_defined?(str)
raise TypeError, "The constant: '#{str}' is not defined in the module: '#{protocol_type}'."
end
raise TypeError, "Non-existent protocol type passed: '#{protocol_type}'."
end
|