Class: ActiveVlc::ParameterSet

Inherits:
Hash
  • Object
show all
Defined in:
lib/activevlc/parameters/parameter_set.rb

Instance Method Summary collapse

Instance Method Details

#<<(param) ⇒ Object

Equivalent for set = param



5
6
7
8
# File 'lib/activevlc/parameters/parameter_set.rb', line 5

def <<(param)
  self[param.name.to_sym] = param
  self
end

#[](name) ⇒ Object



10
11
12
# File 'lib/activevlc/parameters/parameter_set.rb', line 10

def [](name)
  super name.to_sym
end

#[]=(name, value) ⇒ Object



13
14
15
# File 'lib/activevlc/parameters/parameter_set.rb', line 13

def []=(name, value)
  super name.to_sym, value
end

#has_param?(name) ⇒ Boolean

Does this parameter set has a param called ‘name’ ?

Returns:

  • (Boolean)


18
19
20
# File 'lib/activevlc/parameters/parameter_set.rb', line 18

def has_param?(name)
  self.has_key? name.to_sym
end

#set_value_for(name, value) ⇒ Object

Set the value for the parameter named ‘name’



28
29
30
# File 'lib/activevlc/parameters/parameter_set.rb', line 28

def set_value_for(name, value)
  self[name.to_sym].value = value
end

#value_for(name) ⇒ Object

Get the value for the parameter named ‘name’



23
24
25
# File 'lib/activevlc/parameters/parameter_set.rb', line 23

def value_for(name)
  self[name.to_sym].value
end

#visit(params) ⇒ Object

Merge a hash of ‘name: value’ into the parameter set



34
35
36
37
38
# File 'lib/activevlc/parameters/parameter_set.rb', line 34

def visit(params)
  params.each do |name, value|
    set_value_for name, value if has_param? name
  end
end