Class: Proxy::Dns::Dnsmasq::Openwrt::DSL::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_proxy_dns_dnsmasq/backend/openwrt.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, name = nil) ⇒ Config

Returns a new instance of Config.



94
95
96
97
98
# File 'lib/smart_proxy_dns_dnsmasq/backend/openwrt.rb', line 94

def initialize(type, name = nil)
  @type = type.to_sym
  @name = name
  @options = {}
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



92
93
94
# File 'lib/smart_proxy_dns_dnsmasq/backend/openwrt.rb', line 92

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



92
93
94
# File 'lib/smart_proxy_dns_dnsmasq/backend/openwrt.rb', line 92

def options
  @options
end

#typeObject (readonly)

Returns the value of attribute type.



92
93
94
# File 'lib/smart_proxy_dns_dnsmasq/backend/openwrt.rb', line 92

def type
  @type
end

Instance Method Details

#to_sObject



100
101
102
103
104
105
106
107
108
109
110
# File 'lib/smart_proxy_dns_dnsmasq/backend/openwrt.rb', line 100

def to_s
  "config #{type} #{name}\n" + options.map do |name, value|
    if value.is_a? Array
      value.map do|val|
        "        list #{name} '#{val}'"
      end.join "\n"
    else
      "        option #{name} '#{value}'"
    end
  end.join("\n") + "\n"
end