lib/osm/badge.rb in osm-1.0.2 vs lib/osm/badge.rb in osm-1.0.3

- old
+ new

@@ -193,12 +193,12 @@ self.class.subscription_required end class Requirement - include ::ActiveAttr::MassAssignmentSecurity - include ::ActiveAttr::Model + include ActiveModel::MassAssignmentSecurity + include ActiveAttr::Model # @!attribute [rw] badge # @return [Osm::Badge] the badge the requirement belongs to # @!attribute [rw] name # @return [String] the name of the badge @@ -298,11 +298,11 @@ # Get the total number of gained requirements # @return [Fixnum] the total number of requirements considered gained def total_gained count = 0 requirements.each do |field, data| - next if data.blank? || data[0].downcase.eql?('x') + next if data.blank? || data.to_s[0].downcase.eql?('x') count += 1 end return count end @@ -326,11 +326,11 @@ count = {} requirements.each do |field, data| field = field.split('_')[0] unless field.eql?('y') count[field] ||= 0 - next if data.blank? || data[0].downcase.eql?('x') + next if data.blank? || data.to_s[0].downcase.eql?('x') count[field] += 1 else # A total 'section' count['a'] = data.to_i end @@ -350,11 +350,11 @@ return (started > completed) if badge.type.eql?(:staged) # It's a staged badge return false if completed? requirements.each do |key, value| case key.split('_')[0] when 'a' - return true unless value.blank? || value[0].downcase.eql?('x') + return true unless value.blank? || value.to_s[0].downcase.eql?('x') when 'y' return true if (requirements['y_01'].to_i > 0) end end return false @@ -384,10 +384,10 @@ start_group = 'abcde'[completed] # Requirements use the group letter to denote stage started = 'z' requirements.each do |key, value| next if key[0] < start_group # This stage is marked as completed next if key[0] > started # This stage is after the stage currently started - started = key[0] unless value.blank? || value[0].downcase.eql?('x') + started = key[0] unless value.blank? || value.to_s[0].downcase.eql?('x') end return started.eql?('z') ? 0 : 'abcde'.index(started)+1 end return 0 end