Class: RadiusRB::Dictionary

Inherits:
Object
  • Object
show all
Includes:
RadiusRB
Defined in:
lib/radiusrb/dictionary.rb

Constant Summary collapse

DEFAULT_DICTIONARIES_PATH =
::File.join(::File.dirname(__FILE__), '..', '..', 'templates')

Constants included from RadiusRB

LIBPATH, PATH

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RadiusRB

libpath, path, require_all_libs_relative_to

Constructor Details

#initialize(initial_path = nil) ⇒ Dictionary

Returns a new instance of Dictionary.



26
27
28
29
30
31
# File 'lib/radiusrb/dictionary.rb', line 26

def initialize(initial_path = nil)
  @attributes = AttributesCollection.new
  @vendors = VendorCollection.new

  read_files initial_path if initial_path
end

Class Method Details

.defaultObject



73
74
75
# File 'lib/radiusrb/dictionary.rb', line 73

def default
  new DEFAULT_DICTIONARIES_PATH
end

Instance Method Details

#attribute_id_defined?(id) ⇒ Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/radiusrb/dictionary.rb', line 55

def attribute_id_defined?(id)
  !@attributes.find_by_id(id).nil?
end

#attribute_name_defined?(name) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/radiusrb/dictionary.rb', line 51

def attribute_name_defined?(name)
  !@attributes.find_by_name(name).nil?
end

#attributesObject



63
64
65
# File 'lib/radiusrb/dictionary.rb', line 63

def attributes
  @attributes
end

#find_attribute_by_id(id) ⇒ Object



47
48
49
# File 'lib/radiusrb/dictionary.rb', line 47

def find_attribute_by_id(id)
  @attributes.find_by_id(id)
end

#find_attribute_by_name(name) ⇒ Object



43
44
45
# File 'lib/radiusrb/dictionary.rb', line 43

def find_attribute_by_name(name)
  @attributes.find_by_name(name)
end

#nameObject



67
68
69
# File 'lib/radiusrb/dictionary.rb', line 67

def name
  "Dictionary"
end

#read_files(path) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/radiusrb/dictionary.rb', line 33

def read_files(path)
  dict_files = File.join(path, "*")
  Dir.glob(dict_files) { |file|
    read_attributes(file)
  }
  Dir.glob(dict_files) { |file|
    read_values(file)
  }
end

#vendorsObject



59
60
61
# File 'lib/radiusrb/dictionary.rb', line 59

def vendors
  @vendors
end