Class: Procedo::Procedure::Setter

Inherits:
Field
  • Object
show all
Defined in:
lib/procedo/procedure/setter.rb

Overview

An Attribute defines an information to complete

Direct Known Subclasses

Attribute, Reading

Instance Attribute Summary collapse

Attributes inherited from Field

#name, #parameter

Instance Method Summary collapse

Methods inherited from Field

code_trees, count_variables, dependent_parameters, detect, detect_environment_variable, detect_parameter, each, parse!

Constructor Details

#initialize(parameter, name, options = {}) ⇒ Setter

Returns a new instance of Setter.


10
11
12
13
14
15
16
# File 'lib/procedo/procedure/setter.rb', line 10

def initialize(parameter, name, options = {})
  super(parameter, name, options)
  @hidden = !!options[:hidden]
  self.default_value = options[:default_value]
  self.condition = options[:if]
  @computations = []
end

Instance Attribute Details

#computationsObject (readonly)

Returns the value of attribute computations


8
9
10
# File 'lib/procedo/procedure/setter.rb', line 8

def computations
  @computations
end

Instance Method Details

#accessible?Boolean

Returns true if setter can be accessed by a human during recording process.

Returns:

  • (Boolean)

20
21
22
# File 'lib/procedo/procedure/setter.rb', line 20

def accessible?
  !@hidden
end

#add_computation(expression, destinations, options = {}) ⇒ Object


33
34
35
# File 'lib/procedo/procedure/setter.rb', line 33

def add_computation(expression, destinations, options = {})
  @computations << Procedo::Procedure::Computation.new(@parameter, expression, options.merge(expression: expression, destinations: destinations))
end

#depend_on?(parameter_name) ⇒ Boolean

Returns:

  • (Boolean)

28
29
30
31
# File 'lib/procedo/procedure/setter.rb', line 28

def depend_on?(parameter_name)
  default_value_with_parameter?(parameter_name) ||
    condition_with_parameter?(parameter_name)
end

#hidden?Boolean

Returns:

  • (Boolean)

24
25
26
# File 'lib/procedo/procedure/setter.rb', line 24

def hidden?
  @hidden
end