Class: Phut::Syntax::VswitchDirective
- Defined in:
- lib/phut/syntax/vswitch_directive.rb
Overview
The ‘vswitch(name) { …attributes… }’ directive.
Instance Method Summary collapse
- #dpid(value) ⇒ Object (also: #datapath_id)
-
#initialize(alias_name, &block) ⇒ VswitchDirective
constructor
A new instance of VswitchDirective.
Methods inherited from Directive
#[], attribute, #method_missing
Constructor Details
#initialize(alias_name, &block) ⇒ VswitchDirective
Returns a new instance of VswitchDirective.
11 12 13 14 |
# File 'lib/phut/syntax/vswitch_directive.rb', line 11 def initialize(alias_name, &block) @attributes = { name: alias_name, port: 6653 } instance_eval(&block) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Phut::Syntax::Directive
Instance Method Details
#dpid(value) ⇒ Object Also known as: datapath_id
16 17 18 19 20 21 22 23 24 |
# File 'lib/phut/syntax/vswitch_directive.rb', line 16 def dpid(value) dpid = if value.is_a?(String) && /^0x/=~ value value.hex else value.to_i end @attributes[:dpid] = dpid @attributes[:name] ||= format('%#x', @attributes[:dpid]) end |