Class: Osm::Badge::Requirement

Inherits:
Object
  • Object
show all
Includes:
ActiveAttr::Model, ActiveModel::MassAssignmentSecurity
Defined in:
lib/osm/badge.rb,
lib/osm/badge.rb

Overview

Ensure the constant exists for the validators

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeObject

Initialize a new Badge

Parameters:

  • attributes (Hash)

    The hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)



# File 'lib/osm/badge.rb', line 226

Instance Attribute Details

#badgeOsm::Badge

Returns the badge the requirement belongs to.

Returns:

  • (Osm::Badge)

    the badge the requirement belongs to



212
# File 'lib/osm/badge.rb', line 212

attribute :badge, :type => Object

#descriptionString

Returns a description of the badge.

Returns:

  • (String)

    a description of the badge



212
# File 'lib/osm/badge.rb', line 212

attribute :badge, :type => Object

#editableBoolean

Returns:

  • (Boolean)


212
# File 'lib/osm/badge.rb', line 212

attribute :badge, :type => Object

#fieldString

Returns the field for the requirement (passed to OSM).

Returns:

  • (String)

    the field for the requirement (passed to OSM)



212
# File 'lib/osm/badge.rb', line 212

attribute :badge, :type => Object

#nameString

Returns the name of the badge.

Returns:

  • (String)

    the name of the badge



212
# File 'lib/osm/badge.rb', line 212

attribute :badge, :type => Object

Instance Method Details

#<=>(another) ⇒ Object

Compare Badge::Requirement based on badge then field



231
232
233
234
235
# File 'lib/osm/badge.rb', line 231

def <=>(another)
  result = self.badge <=> another.try(:badge)
  result = self.field <=> another.try(:field) if result == 0
  return result
end

#inspectObject



237
238
239
# File 'lib/osm/badge.rb', line 237

def inspect
  Osm.inspect_instance(self, options={:replace_with => {'badge' => :osm_key}})
end