Sha256: eca05009d0406a8f9d98102fa8baff4e19b5248e26562006141abe904b379497

Contents?: true

Size: 1.39 KB

Versions: 9

Compression:

Stored size: 1.39 KB

Contents

module Osm

  class Grouping
    include ::ActiveAttr::MassAssignmentSecurity
    include ::ActiveAttr::Model

    # @!attribute [rw] id
    #   @return [Fixnum] the id for grouping
    # @!attribute [rw] name
    #   @return [String] the name of the grouping
    # @!attribute [rw] active
    #   @return [Boolean] wether the grouping is active
    # @!attribute [rw] points
    #   @return [Fixnum] the points awarded to the grouping

    attribute :id, :type => Integer
    attribute :name, :type => String
    attribute :active, :type => Boolean
    attribute :points, :type => Integer

    attr_accessible :id, :name, :active, :points

    validates_numericality_of :id, :only_integer=>true, :greater_than_or_equal_to=>-2
    validates_presence_of :name
    validates_numericality_of :points, :only_integer=>true
    validates_presence_of :active


    # @!method initialize
    #   Initialize a new Term
    #   @param [Hash] attributes the hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)


    # Initialize a new Grouping from api data
    # @param [Hash] data the hash of data provided by the API
    def self.from_api(data)
      new({
        :id => Osm::to_i_or_nil(data['patrolid']),
        :name => data['name'],
        :active => (data['active'] == 1),
        :points => Osm::to_i_or_nil(data['points']),
      })
    end

  end # Class Grouping

end # Module

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
osm-0.0.26 lib/osm/grouping.rb
osm-0.0.25 lib/osm/grouping.rb
osm-0.0.24 lib/osm/grouping.rb
osm-0.0.23 lib/osm/grouping.rb
osm-0.0.22 lib/osm/grouping.rb
osm-0.0.21 lib/osm/grouping.rb
osm-0.0.20 lib/osm/grouping.rb
osm-0.0.19 lib/osm/grouping.rb
osm-0.0.18 lib/osm/grouping.rb