Class: Puppet::Pops::Evaluator::CompareOperator

Inherits:
Object
  • Object
show all
Includes:
Runtime3Support, Utils
Defined in:
lib/puppet/pops/evaluator/compare_operator.rb

Overview

All other objects are equal if they are ruby #== equal

Constant Summary

Constants included from Runtime3Support

Runtime3Support::NAME_SPACE_SEPARATOR

Instance Method Summary collapse

Methods included from Runtime3Support

#add_relationship, #call_function, #capitalize_qualified_name, #coerce_numeric, #convert, #create_local_scope_from, #create_match_scope_from, #create_resource_defaults, #create_resource_overrides, #create_resource_parameter, #create_resources, #diagnostic_producer, #external_call_function, #extract_file_line, #fail, #find_resource, #get_resource_parameter_value, #get_scope_nesting_level, #get_variable_value, #is_parameter_of_resource?, #is_true?, #optionally_fail, #runtime_issue, #set_match_data, #set_scope_nesting_level, #set_variable, #variable_bound?, #variable_exists?

Methods included from Utils

is_absolute?, is_numeric?, match_to_fp, name_to_segments, relativize_name, to_n, to_n_with_radix

Constructor Details

#initializeCompareOperator

Returns a new instance of CompareOperator.



21
22
23
24
25
26
# File 'lib/puppet/pops/evaluator/compare_operator.rb', line 21

def initialize
  @@equals_visitor  ||= Visitor.new(self, "equals", 1, 1)
  @@compare_visitor ||= Visitor.new(self, "cmp", 1, 1)
  @@match_visitor ||= Visitor.new(self, "match", 2, 2)
  @@include_visitor ||= Visitor.new(self, "include", 2, 2)
end

Instance Method Details

#compare(a, b) ⇒ Object

Performs a comparison of a and b, and return > 0 if a is bigger, 0 if equal, and < 0 if b is bigger. Comparison of String vs. Numeric always compares using numeric.



34
35
36
# File 'lib/puppet/pops/evaluator/compare_operator.rb', line 34

def compare(a, b)
  @@compare_visitor.visit_this_1(self, a, b)
end

#equals(a, b) ⇒ Object



28
29
30
# File 'lib/puppet/pops/evaluator/compare_operator.rb', line 28

def equals(a, b)
  @@equals_visitor.visit_this_1(self, a, b)
end

#include?(a, b, scope) ⇒ Boolean

Answers is b included in a

Returns:

  • (Boolean)


44
45
46
# File 'lib/puppet/pops/evaluator/compare_operator.rb', line 44

def include?(a, b, scope)
  @@include_visitor.visit_this_2(self, a, b, scope)
end

#match(a, b, scope = nil) ⇒ Object

Performs a match of a and b, and returns true if b matches a



39
40
41
# File 'lib/puppet/pops/evaluator/compare_operator.rb', line 39

def match(a, b, scope = nil)
  @@match_visitor.visit_this_2(self, b, a, scope)
end