Class: Radiustar::Attribute

Inherits:
Object
  • Object
show all
Includes:
Radiustar
Defined in:
lib/radiustar/dictionary/attributes.rb

Constant Summary

Constants included from Radiustar

LIBPATH, PATH

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Radiustar

#inspect, libpath, path, require_all_libs_relative_to, version

Constructor Details

#initialize(name, id, type, vendor = nil) ⇒ Attribute

Returns a new instance of Attribute.



43
44
45
46
47
48
49
# File 'lib/radiustar/dictionary/attributes.rb', line 43

def initialize(name, id, type, vendor=nil)
  @values = ValuesCollection.new
  @name = name
  @id = id.to_i
  @type = type
  @vendor = vendor if vendor
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



41
42
43
# File 'lib/radiustar/dictionary/attributes.rb', line 41

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



41
42
43
# File 'lib/radiustar/dictionary/attributes.rb', line 41

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



41
42
43
# File 'lib/radiustar/dictionary/attributes.rb', line 41

def type
  @type
end

#vendorObject (readonly)

Returns the value of attribute vendor.



41
42
43
# File 'lib/radiustar/dictionary/attributes.rb', line 41

def vendor
  @vendor
end

Instance Method Details

#add_value(name, id) ⇒ Object



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

def add_value(name, id)
  @values.add(name, id.to_i)
end

#find_values_by_id(id) ⇒ Object



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

def find_values_by_id(id)
  @values.find_by_id(id.to_i)
end

#find_values_by_name(name) ⇒ Object



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

def find_values_by_name(name)
  @values.find_by_name(name)
end

#has_values?Boolean

Returns:

  • (Boolean)


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

def has_values?
  !@values.empty?
end

#valuesObject



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

def values
  @values
end

#vendor?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/radiustar/dictionary/attributes.rb', line 71

def vendor?
  !!@vendor
end