/gist:dd5e84cec2b8cb4adc8e Secret
Last active
August 29, 2015 14:05
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module DynamicNetworkGraph | |
class NetworkFlow | |
Fields = [ :srcAddr, | |
:dstAddr, | |
:srcPort, | |
:dstPort, | |
:protocol, | |
:start, | |
:end, | |
:packets, | |
:transferred, | |
:status, | |
] | |
attr_accessor :srcAddr | |
attr_accessor :dstAddr | |
attr_accessor :srcPort | |
attr_accessor :dstPort | |
attr_accessor :protocol | |
attr_accessor :start | |
attr_accessor :end | |
attr_accessor :packets | |
attr_accessor :transferred | |
attr_accessor :status | |
def fromFields(sep,line) | |
Fields.zip(line.split(sep)).map {|(iv,val)| self.instance_variable_set(iv,val)} | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
rebecca@rebecca-laptop:~/projects/network_graph_gen$ pry
[1] pry(main)> require './networkFlow.rb'
=> true
[2] pry(main)> foo = DynamicNetworkGraph::NetworkFlow.new
=> #DynamicNetworkGraph::NetworkFlow:0x0000000417b9f8
[3] pry(main)> foo.fromFields(",","a,b,c,d")
NameError:
srcAddr' is not allowed as an instance variable name from /home/rebecca/projects/network_graph_gen/networkFlow.rb:28:in
instance_variable_set'