lib/openstudio-standards/standards/necb/NECB2011/data/standards_data.rb in openstudio-standards-0.6.0.rc2 vs lib/openstudio-standards/standards/necb/NECB2011/data/standards_data.rb in openstudio-standards-0.6.3
- old
+ new
@@ -187,14 +187,13 @@
# If capacity was specified, narrow down the matching objects
if capacity.nil?
matching_objects = search_criteria_matching_objects
else
- # Round up if capacity is an integer
- if capacity == capacity.round
- capacity += (capacity * 0.01)
- end
+ # Convert to a float in case not already
+ capacity = capacity.to_f
+
search_criteria_matching_objects.each do |object|
# Skip objects that don't have fields for minimum_capacity and maximum_capacity
next if !object.key?('minimum_capacity') || !object.key?('maximum_capacity')
# Skip objects that don't have values specified for minimum_capacity and maximum_capacity
next if object['minimum_capacity'].nil? || object['maximum_capacity'].nil?
@@ -206,11 +205,11 @@
matching_objects << object
end
# If no object was found, round the capacity down a little
# to avoid issues where the number fell between the limits
# in the json file.
- if matching_objects.size.zero?
+ if matching_objects.empty?
capacity *= 0.99
search_criteria_matching_objects.each do |object|
# Skip objects that don't have fields for minimum_capacity and maximum_capacity
next if !object.key?('minimum_capacity') || !object.key?('maximum_capacity')
# Skip objects that don't have values specified for minimum_capacity and maximum_capacity
@@ -224,11 +223,11 @@
end
end
end
# Check the number of matching objects found
- if matching_objects.size.zero?
+ if matching_objects.empty?
desired_object = nil
# OpenStudio::logFree(OpenStudio::Warn, 'openstudio.standards.Model', "Find objects search criteria returned no results. Search criteria: #{search_criteria}, capacity = #{capacity}. Called from #{caller(0)[1]}.")
end
# if new_matching_objects != matching_objects
@@ -290,14 +289,13 @@
# If capacity was specified, narrow down the matching objects
if capacity.nil?
matching_objects = search_criteria_matching_objects
else
- # Round up if capacity is an integer
- if capacity == capacity.round
- capacity += (capacity * 0.01)
- end
+ # Convert to a float in case not already
+ capacity = capacity.to_f
+
search_criteria_matching_objects.each do |object|
# Skip objects that don't have fields for minimum_capacity and maximum_capacity
next if !object.key?('minimum_capacity') || !object.key?('maximum_capacity')
# Skip objects that don't have values specified for minimum_capacity and maximum_capacity
next if object['minimum_capacity'].nil? || object['maximum_capacity'].nil?
@@ -309,11 +307,11 @@
matching_objects << object
end
# If no object was found, round the capacity down a little
# to avoid issues where the number fell between the limits
# in the json file.
- if matching_objects.size.zero?
+ if matching_objects.empty?
capacity *= 0.99
search_criteria_matching_objects.each do |object|
# Skip objects that don't have fields for minimum_capacity and maximum_capacity
next if !object.key?('minimum_capacity') || !object.key?('maximum_capacity')
# Skip objects that don't have values specified for minimum_capacity and maximum_capacity
@@ -343,10 +341,10 @@
end
matching_objects = date_matching_objects
end
# Check the number of matching objects found
- if matching_objects.size.zero?
+ if matching_objects.empty?
desired_object = nil
# OpenStudio::logFree(OpenStudio::Warn, 'openstudio.standards.Model', "Find object search criteria returned no results. Search criteria: #{search_criteria}, capacity = #{capacity}. Called from #{caller(0)[1]}")
elsif matching_objects.size == 1
desired_object = matching_objects[0]
else
\ No newline at end of file