<commit_before>require_relative 'delayed_constraint'

class TemperatureConverter

	constraint :relationFahrCent, "{ :c * 1.8 == :f - 32.0 }"

	def initialize
		@centigrade = 130.0
		@fahrenheit = 110.0

		puts('@centigrade: ' + @centigrade.to_s)
		puts('@fahrenheit: ' + @fahrenheit.to_s)

		once :relationFahrCent, {:c => :@centigrade, :f => :@fahrenheit}, binding

		puts('@centigrade: ' + @centigrade.to_s)
		puts('@fahrenheit: ' + @fahrenheit.to_s)
	end

	def example
		# not working because of Topaz bug, see https://github.com/topazproject/topaz/issues/839
	 	cent = 50.0
		fahr = 100.0
		
		puts('cent: ' + cent.to_s)
		puts('fahr: ' + fahr.to_s)

		always :relationFahrCent, {:c => :cent, :f => :fahr}, binding
	
		puts('cent: ' + cent.to_s)
		puts('fahr: ' + fahr.to_s)
	end
end

t = TemperatureConverter.new
t.example<commit_msg>Extend temperature converter example<commit_after>require_relative 'delayed_constraint'

class TemperatureConverter

	constraint :relationFahrCent, "{ :c * 1.8 == :f - 32.0 }"

	def initialize
		@centigrade = 130.0
		@fahrenheit = 110.0

		puts('@centigrade: ' + @centigrade.to_s)
		puts('@fahrenheit: ' + @fahrenheit.to_s)

		always :relationFahrCent, {:c => :@centigrade, :f => :@fahrenheit}, binding

		puts('@centigrade: ' + @centigrade.to_s)
		puts('@fahrenheit: ' + @fahrenheit.to_s)

		@centigrade = 120.0

		puts('@centigrade: ' + @centigrade.to_s)
		puts('@fahrenheit: ' + @fahrenheit.to_s)
	end

	def example
		# not working because of Topaz bug, see https://github.com/topazproject/topaz/issues/839
	 	cent = 50.0
		fahr = 100.0
		
		puts('cent: ' + cent.to_s)
		puts('fahr: ' + fahr.to_s)

		always :relationFahrCent, {:c => :cent, :f => :fahr}, binding
	
		puts('cent: ' + cent.to_s)
		puts('fahr: ' + fahr.to_s)
	end
end

t = TemperatureConverter.new
t.example
{'fraction_non_alphanumeric': 0.16161059018201876, 'fraction_numerical': 0.027578599007170437, 'mean_word_length': 3.9562841530054644, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3607237', 'n_tokens_mistral': 840, 'n_tokens_neox': 734, 'n_words': 140}