Class: CIM::Method
- Inherits:
-
ClassFeature
- Object
- NamedElement
- ClassFeature
- CIM::Method
- Defined in:
- lib/cim/method.rb
Overview
A Method defines a function member of a Class.
For data members, see Property.
Instance Attribute Summary
Attributes inherited from ClassFeature
Attributes inherited from NamedElement
Instance Method Summary collapse
-
#initialize(type, name, qualifiers = nil, parameters = nil) ⇒ Method
constructor
Create a Method with return type (Type) and name (String), optional Qualifiers and parameters (Property).
-
#method? ⇒ Boolean
Makes a Method recognizable in the set of Class features.
-
#method_missing(name, *args) ⇒ Object
Check for qualifiers.
-
#parameters ⇒ Object
parameters accessor.
-
#to_s ⇒ Object
returns a string representation in MOF syntax format.
Methods inherited from ClassFeature
Methods inherited from NamedElement
Constructor Details
#initialize(type, name, qualifiers = nil, parameters = nil) ⇒ Method
25 26 27 28 |
# File 'lib/cim/method.rb', line 25 def initialize type, name, qualifiers = nil, parameters = nil @parameters = parameters super type,name,qualifiers end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
Check for qualifiers
# check for existance
method.qualifier? -> true or false
# check value
method.description -> String or nil
57 58 59 60 61 62 63 |
# File 'lib/cim/method.rb', line 57 def method_missing name, *args if name.to_s[-1,1] == "?" @qualifiers && @qualifiers.include?(name.to_s[0...-1]) else (@qualifiers[name].value || @qualifiers[name].declaration.default) rescue nil end end |
Instance Method Details
#method? ⇒ Boolean
Makes a Method recognizable in the set of Class features.
38 39 40 |
# File 'lib/cim/method.rb', line 38 def method? true end |
#parameters ⇒ Object
parameters accessor
32 33 34 |
# File 'lib/cim/method.rb', line 32 def parameters @parameters || [] end |
#to_s ⇒ Object
returns a string representation in MOF syntax format
44 45 46 47 |
# File 'lib/cim/method.rb', line 44 def to_s p = parameters.join(", ") "#{super}(#{p})" end |