Class: Xen::Vif
- Inherits:
-
Object
- Object
- Xen::Vif
- Defined in:
- lib/xen/config_file.rb
Overview
Virtual Network Interface
Instance Attribute Summary collapse
-
#bridge ⇒ Object
Returns the value of attribute bridge.
-
#ip ⇒ Object
Returns the value of attribute ip.
-
#mac ⇒ Object
Returns the value of attribute mac.
-
#vifname ⇒ Object
Returns the value of attribute vifname.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Vif
constructor
A new instance of Vif.
- #to_str ⇒ Object
Constructor Details
#initialize(*args) ⇒ Vif
Returns a new instance of Vif.
97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/xen/config_file.rb', line 97 def initialize(*args) = args. # Validations - move them out into a validate function raise(ValidationFailed, 'message') if [:vifname] == 'foos' @ip = [:ip].to_s.gsub /['"]/, '' @mac = [:mac].to_s.gsub /['"]/, '' @bridge = [:bridge].to_s.gsub /['"]/, '' @vifname = [:vifname].to_s.gsub /['"]/, '' end |
Instance Attribute Details
#bridge ⇒ Object
Returns the value of attribute bridge.
95 96 97 |
# File 'lib/xen/config_file.rb', line 95 def bridge @bridge end |
#ip ⇒ Object
Returns the value of attribute ip.
95 96 97 |
# File 'lib/xen/config_file.rb', line 95 def ip @ip end |
#mac ⇒ Object
Returns the value of attribute mac.
95 96 97 |
# File 'lib/xen/config_file.rb', line 95 def mac @mac end |
#vifname ⇒ Object
Returns the value of attribute vifname.
95 96 97 |
# File 'lib/xen/config_file.rb', line 95 def vifname @vifname end |
Class Method Details
.from_str(value) ⇒ Object
109 110 111 112 |
# File 'lib/xen/config_file.rb', line 109 def self.from_str(value) = value.scan(/(\w+)=([^,]+)/).inject({}){ |m, (k, v)| m[k.to_sym] = v; m } new() end |
Instance Method Details
#to_str ⇒ Object
114 115 116 117 118 |
# File 'lib/xen/config_file.rb', line 114 def to_str %w(ip mac bridge vifname).collect { |key| "#{key}=#{instance_variable_get('@' + key)}" unless instance_variable_get('@'+key) == '' }.compact.join(',') end |