Module: Roby::Models::Arguments
- Extended by:
- MetaRuby::Attributes
- Included in:
- Task, TaskServiceModel
- Defined in:
- lib/roby/models/arguments.rb
Overview
Support for argument handling in the relevant models (task services and tasks)
Defined Under Namespace
Classes: Argument
Constant Summary collapse
- NO_DEFAULT_ARGUMENT =
The null object used in #argument to signify that there are no default arguments
nil cannot be used as ‘nil’ is a valid default as well
Object.new
Instance Method Summary collapse
- #argument(argument_name, options) ⇒ Object
-
#arguments ⇒ Array<String>
The list of arguments required by this task model.
-
#default_argument(argname) ⇒ (Boolean,Object)
Access an argument’s default value.
-
#fullfills?(models) ⇒ Boolean
Checks if this model fullfills everything in
models. -
#meaningful_arguments(arguments) ⇒ Object
The part of
argumentsthat is meaningful for this task model.
Instance Method Details
#argument(argument_name, options) ⇒ Object
24 |
# File 'lib/roby/models/arguments.rb', line 24 inherited_attribute("argument", "__arguments", map: true) { Hash.new } |
#arguments ⇒ Array<String>
27 28 29 |
# File 'lib/roby/models/arguments.rb', line 27 def arguments each_argument.map { |name, _| name } end |
#default_argument(argname) ⇒ (Boolean,Object)
Access an argument’s default value
77 78 79 80 81 |
# File 'lib/roby/models/arguments.rb', line 77 def default_argument(argname) if (arg = find_argument(argname)) && arg.has_default? return true, arg.default end end |
#fullfills?(models) ⇒ Boolean
Checks if this model fullfills everything in models
96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/roby/models/arguments.rb', line 96 def fullfills?(models) if !models.respond_to?(:each) models = [models] end for tag in models if !has_ancestor?(tag) return false end end true end |
#meaningful_arguments(arguments) ⇒ Object
The part of arguments that is meaningful for this task model
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/roby/models/arguments.rb', line 84 def meaningful_arguments(arguments) self_arguments = self.arguments result = Hash.new arguments.each_assigned_argument do |key, value| if self_arguments.include?(key) result[key] = value end end result end |