Class: Trema::StatsHelper
- Inherits:
-
Object
- Object
- Trema::StatsHelper
- Defined in:
- ruby/trema/stats-helper.rb
Direct Known Subclasses
AggregateStatsReply, DescStatsReply, FlowStatsReply, PortStatsReply, QueueStatsReply, TableStatsReply, VendorStatsReply
Instance Method Summary collapse
-
#initialize(fields, options = {}) ⇒ void
constructor
Invoked by each StatsReply subclass to assign their instance attributes to a value.
-
#to_s ⇒ String
An alphabetically sorted text of attribute name/value pairs.
Constructor Details
#initialize(fields, options = {}) ⇒ void
Invoked by each StatsReply subclass to assign their instance attributes to a value.
36 37 38 39 40 |
# File 'ruby/trema/stats-helper.rb', line 36 def initialize fields, fields.each do |field| instance_variable_set( "@#{field}", [field.intern] ) end end |
Instance Method Details
#to_s ⇒ String
Returns an alphabetically sorted text of attribute name/value pairs.
47 48 49 50 51 52 53 54 |
# File 'ruby/trema/stats-helper.rb', line 47 def to_s str = super.to_s + "\n" instance_variables.sort.each do |var| str += "#{var[1..var.length]}: #{instance_variable_get( var ).to_s}\n" end # remove the last newline character str[0..-2] end |