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_boolean?, #is_parameter_of_resource?, #is_true?, #optionally_fail, #resource_to_ptype, #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.


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

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.


32
33
34
# File 'lib/puppet/pops/evaluator/compare_operator.rb', line 32

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

#equals(a, b) ⇒ Object


26
27
28
# File 'lib/puppet/pops/evaluator/compare_operator.rb', line 26

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)

42
43
44
# File 'lib/puppet/pops/evaluator/compare_operator.rb', line 42

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


37
38
39
# File 'lib/puppet/pops/evaluator/compare_operator.rb', line 37

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