Class: Pio::Hello
- Inherits:
-
Object
- Object
- Pio::Hello
- Extended by:
- Forwardable
- Defined in:
- lib/pio/hello.rb,
lib/pio/hello/format.rb
Overview
OpenFlow 1.0 Hello message
Defined Under Namespace
Classes: Format
Class Method Summary collapse
-
.read(raw_data) ⇒ Pio::Hello
Parses
raw_data
binary string into a Hello message object.
Instance Method Summary collapse
-
#initialize(user_options = {}) ⇒ Hello
constructor
Creates a Hello OpenFlow message.
Constructor Details
#initialize ⇒ Hello #initialize(transaction_id) ⇒ Hello #initialize(user_options) ⇒ Hello
Creates a Hello OpenFlow message.
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/pio/hello.rb', line 55 def initialize( = {}) if .respond_to?(:to_i) @options = { transaction_id: .to_i } elsif .respond_to?(:[]) @options = .dup @options[:transaction_id] ||= @options[:xid] @options[:transaction_id] = 0 unless @options[:transaction_id] else fail TypeError end @data = Format.new(@options) end |
Class Method Details
.read(raw_data) ⇒ Pio::Hello
Parses raw_data
binary string into a Hello message object.
25 26 27 28 29 30 31 32 33 |
# File 'lib/pio/hello.rb', line 25 def self.read(raw_data) hello = allocate begin hello.instance_variable_set :@data, Format.read(raw_data) rescue BinData::ValidityError raise ParseError, $ERROR_INFO. end hello end |