Class: Radiustar::Attribute

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, id, type) ⇒ Attribute

Returns a new instance of Attribute.



29
30
31
32
33
34
# File 'lib/radiustar/dictionary/attributes.rb', line 29

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

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



27
28
29
# File 'lib/radiustar/dictionary/attributes.rb', line 27

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



27
28
29
# File 'lib/radiustar/dictionary/attributes.rb', line 27

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



27
28
29
# File 'lib/radiustar/dictionary/attributes.rb', line 27

def type
  @type
end

Instance Method Details

#add_value(name, id) ⇒ Object



36
37
38
# File 'lib/radiustar/dictionary/attributes.rb', line 36

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

#find_values_by_id(id) ⇒ Object



44
45
46
# File 'lib/radiustar/dictionary/attributes.rb', line 44

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

#find_values_by_name(name) ⇒ Object



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

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

#has_values?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/radiustar/dictionary/attributes.rb', line 48

def has_values?
  !@values.empty?
end