Class: CollectdServer::Packet::Part
- Inherits:
-
Object
- Object
- CollectdServer::Packet::Part
- Defined in:
- lib/collectd_server/packet.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Class Method Summary collapse
- .add_type(klass, number) ⇒ Object
- .class_for(type) ⇒ Object
- .part_for(type, content) ⇒ Object
- .type(number) ⇒ Object
Instance Method Summary collapse
-
#initialize(content) ⇒ Part
constructor
A new instance of Part.
Constructor Details
#initialize(content) ⇒ Part
Returns a new instance of Part.
95 96 97 |
# File 'lib/collectd_server/packet.rb', line 95 def initialize(content) @content = content end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
71 72 73 |
# File 'lib/collectd_server/packet.rb', line 71 def content @content end |
Class Method Details
.add_type(klass, number) ⇒ Object
78 79 80 81 |
# File 'lib/collectd_server/packet.rb', line 78 def self.add_type(klass, number) @types ||= {} @types[number] = klass end |
.class_for(type) ⇒ Object
91 92 93 |
# File 'lib/collectd_server/packet.rb', line 91 def self.class_for(type) @types[type] end |
.part_for(type, content) ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/collectd_server/packet.rb', line 83 def self.part_for(type, content) if klass = self.class_for(type) klass.new(content) else warn "Unrecognized type %x" % type end end |