Class: Snmp2mkr::ConfigTypes::MetricDefinitionCollection

Inherits:
Base
  • Object
show all
Defined in:
lib/snmp2mkr/config_types/metric_definition_collection.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#binded_context

Instance Method Summary collapse

Methods inherited from Base

#bind_context, #children, #evaluate, #initialize, #inspect

Constructor Details

This class inherits a constructor from Snmp2mkr::ConfigTypes::Base

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



23
24
25
# File 'lib/snmp2mkr/config_types/metric_definition_collection.rb', line 23

def value
  @value
end

Instance Method Details

#[](k) ⇒ Object



15
16
17
# File 'lib/snmp2mkr/config_types/metric_definition_collection.rb', line 15

def [](k)
  @value[k]
end

#collect_childrenObject



19
20
21
# File 'lib/snmp2mkr/config_types/metric_definition_collection.rb', line 19

def collect_children
  @value.values
end

#setup(hash) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/snmp2mkr/config_types/metric_definition_collection.rb', line 7

def setup(hash)
  if !hash.kind_of?(Hash) || hash.any? { |k,v| !k.kind_of?(String) }
    raise TypeError, "#{self.class} must be given a Hash<String, Object)>"
  end

  @value = hash.map { |k, v| [k, MetricDefinition.new([k,v])] }.to_h
end