Class: Oxidized::Source::Source
- Inherits:
-
Object
- Object
- Oxidized::Source::Source
- Defined in:
- lib/oxidized/source/source.rb
Direct Known Subclasses
Defined Under Namespace
Classes: NoConfig
Instance Method Summary collapse
-
#initialize ⇒ Source
constructor
A new instance of Source.
-
#map_group(group) ⇒ Object
search a match for group in the configuration and returns it.
-
#map_model(model) ⇒ Object
search a match for model in the configuration and returns it.
-
#map_value(map_hash, original_value) ⇒ Object
common code of #map_model and #map_group.
- #node_var_interpolate(var) ⇒ Object
Constructor Details
Instance Method Details
#map_group(group) ⇒ Object
search a match for group in the configuration and returns it. If no match is found, return group
group can be matched against a string or a regexp:
group_map:
alias1: groupA
alias2: groupA
alias3: groupB
alias4: groupB
!ruby/regexp /specialgroup/: groupS
aliasN: groupZ
45 46 47 |
# File 'lib/oxidized/source/source.rb', line 45 def map_group(group) map_value(@group_map, group) end |
#map_model(model) ⇒ Object
search a match for model in the configuration and returns it. If no match is found, return model
model can be matched against a string or a regexp:
model_map:
cisco: ios
juniper: junos
!ruby/regexp /procurve/: procurve
29 30 31 |
# File 'lib/oxidized/source/source.rb', line 29 def map_model(model) map_value(@model_map, model) end |
#map_value(map_hash, original_value) ⇒ Object
common code of #map_model and #map_group
12 13 14 15 16 17 18 |
# File 'lib/oxidized/source/source.rb', line 12 def map_value(map_hash, original_value) map_hash.each do |key, new_value| mthd = key.instance_of?(Regexp) ? :match : :eql? return new_value if original_value.send(mthd, key) end original_value end |
#node_var_interpolate(var) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/oxidized/source/source.rb', line 49 def node_var_interpolate(var) case var when "nil" then nil when "false" then false when "true" then true else var end end |