Class: Radiustar::Dictionary
- Inherits:
-
Object
- Object
- Radiustar::Dictionary
show all
- Includes:
- Radiustar
- Defined in:
- lib/radiustar/dictionary.rb
Constant Summary
collapse
- DEFAULT_DICTIONARY_PATH =
::File.join(::File.dirname(__FILE__), '..', '..', 'templates', 'default.txt')
Constants included
from Radiustar
LIBPATH, PATH
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Radiustar
#inspect, libpath, path, require_all_libs_relative_to, version
Constructor Details
#initialize(initial_path = nil) ⇒ Dictionary
Returns a new instance of Dictionary.
Instance Method Details
#attribute_id_defined?(id) ⇒ Boolean
51
52
53
|
# File 'lib/radiustar/dictionary.rb', line 51
def attribute_id_defined?(id)
!@attributes.find_by_id(id).nil?
end
|
#attribute_name_defined?(name) ⇒ Boolean
47
48
49
|
# File 'lib/radiustar/dictionary.rb', line 47
def attribute_name_defined?(name)
!@attributes.find_by_name(name).nil?
end
|
#attributes ⇒ Object
59
60
61
|
# File 'lib/radiustar/dictionary.rb', line 59
def attributes
@attributes
end
|
#find_attribute_by_id(id) ⇒ Object
43
44
45
|
# File 'lib/radiustar/dictionary.rb', line 43
def find_attribute_by_id(id)
@attributes.find_by_id(id)
end
|
#find_attribute_by_name(name) ⇒ Object
39
40
41
|
# File 'lib/radiustar/dictionary.rb', line 39
def find_attribute_by_name(name)
@attributes.find_by_name(name)
end
|
#name ⇒ Object
63
64
65
|
# File 'lib/radiustar/dictionary.rb', line 63
def name
"Dictionary"
end
|
#read(path) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/radiustar/dictionary.rb', line 16
def read(path)
file = File.open(path) do |f|
current_vendor = nil
f.each_line do |line|
next if line =~ /^\#/ split_line = line.split(/\s+/)
next if split_line == []
case split_line.first.upcase
when "ATTRIBUTE"
current_vendor.nil? ? set_attr(split_line) : set_vendor_attr(current_vendor, split_line)
when "VALUE"
current_vendor.nil? ? set_value(split_line) : set_vendor_value(current_vendor, split_line)
when "VENDOR"
add_vendor(split_line)
when "BEGIN-VENDOR"
current_vendor = set_vendor(split_line)
when "END-VENDOR"
current_vendor = nil
end
end
end
end
|
#vendors ⇒ Object
55
56
57
|
# File 'lib/radiustar/dictionary.rb', line 55
def vendors
@vendors
end
|