Class: Protocol::Descriptor
Overview
This class encapsulates the protocol description, to check the classes against, if the Class#conform_to method is called with the protocol constant as an argument.
Instance Method Summary collapse
-
#add_message(message) ⇒ Object
Addes a new Protocol::Message instance to this Protocol::Descriptor object.
-
#initialize(protocol) ⇒ Descriptor
constructor
Creates a new Protocol::Descriptor object.
-
#inspect ⇒ Object
Returns a string representation of this Protocol::Descriptor object.
-
#messages ⇒ Object
Return all the messages stored in this Descriptor instance.
- #to_s ⇒ Object
Constructor Details
#initialize(protocol) ⇒ Descriptor
Creates a new Protocol::Descriptor object.
7 8 9 10 |
# File 'lib/protocol/descriptor.rb', line 7 def initialize(protocol) @protocol = protocol = {} end |
Instance Method Details
#add_message(message) ⇒ Object
Addes a new Protocol::Message instance to this Protocol::Descriptor object.
14 15 16 17 18 |
# File 'lib/protocol/descriptor.rb', line 14 def () .key?(.name) and raise SpecificationError, "A message named #{message.name} was already defined in #@protocol" [.name] = end |
#inspect ⇒ Object
Returns a string representation of this Protocol::Descriptor object.
26 27 28 |
# File 'lib/protocol/descriptor.rb', line 26 def inspect "#<#{self.class}(#@protocol)>" end |
#messages ⇒ Object
Return all the messages stored in this Descriptor instance.
21 22 23 |
# File 'lib/protocol/descriptor.rb', line 21 def .values end |
#to_s ⇒ Object
30 31 32 |
# File 'lib/protocol/descriptor.rb', line 30 def to_s * ', ' end |