Class: Packet
- Inherits:
-
Object
- Object
- Packet
- Defined in:
- lib/packet.rb,
lib/cron_feeder.rb
Overview
this is an abstract packet class that knows how to marshal itself into and out of JSON format
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize ⇒ Packet
constructor
A new instance of Packet.
- #to_json(*a) ⇒ Object
Constructor Details
#initialize ⇒ Packet
Returns a new instance of Packet.
6 7 8 |
# File 'lib/packet.rb', line 6 def initialize raise NotImplementedError.new("#{self.class.name} is an abstract class.") end |
Instance Method Details
#to_json(*a) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/packet.rb', line 9 def to_json(*a) { 'json_class' => self.class.name, 'data' => instance_variables.inject({}) {|m,ivar| m[ivar.sub(/@/,'')] = instance_variable_get(ivar); m } }.to_json(*a) end |