Class: CloudRailSi::ServiceCode::Conditional

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudrail_si/servicecode/commands/Conditional.rb

Instance Method Summary collapse

Constructor Details

#initialize(identifier, compare_function, type_check) ⇒ Conditional

Returns a new instance of Conditional.



6
7
8
9
10
# File 'lib/cloudrail_si/servicecode/commands/Conditional.rb', line 6

def initialize(identifier, compare_function, type_check)
    @identifier = identifier
    @compare_function = compare_function
    @type_check = type_check
end

Instance Method Details

#execute(environment, parameters) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/cloudrail_si/servicecode/commands/Conditional.rb', line 16

def execute(environment, parameters)
    Helper.assert(parameters.length == 3)
    a_obj = parameters[0]
    b_obj = parameters[1]
    relative_end_pos = Helper.resolve(environment, parameters[2])
    Helper.assert(Helper.is_number(relative_end_pos))
    compare = environment.compare_variables(a_obj, b_obj, @identifier, @type_check)
    environment.increment_current_service_code_line(relative_end_pos) if (!@compare_function.call(compare))
end

#get_identifierObject



12
13
14
# File 'lib/cloudrail_si/servicecode/commands/Conditional.rb', line 12

def get_identifier
    @identifier
end