Class: Osm::Grouping
Instance Attribute Summary collapse
-
#active ⇒ Boolean
Wether the grouping is active.
-
#id ⇒ Fixnum
The id for grouping.
-
#name ⇒ String
The name of the grouping.
-
#points ⇒ Fixnum
The points awarded to the grouping.
-
#section_id ⇒ Fixnum
The id for the section this grouping belongs to.
Class Method Summary collapse
-
.get_for_section(api, section, options = {}) ⇒ Array<Osm::Grouping>?
Get the groupings that a section has.
Instance Method Summary collapse
-
#initialize ⇒ Object
constructor
Initialize a new Term.
Methods inherited from Model
Constructor Details
#initialize ⇒ Object
Initialize a new Term
|
# File 'lib/osm/grouping.rb', line 62
|
Instance Attribute Details
#active ⇒ Boolean
Returns wether the grouping is active.
16 |
# File 'lib/osm/grouping.rb', line 16 attribute :id, :type => Integer |
#id ⇒ Fixnum
Returns the id for grouping.
16 |
# File 'lib/osm/grouping.rb', line 16 attribute :id, :type => Integer |
#name ⇒ String
Returns the name of the grouping.
16 |
# File 'lib/osm/grouping.rb', line 16 attribute :id, :type => Integer |
#points ⇒ Fixnum
Returns the points awarded to the grouping.
16 |
# File 'lib/osm/grouping.rb', line 16 attribute :id, :type => Integer |
#section_id ⇒ Fixnum
Returns the id for the section this grouping belongs to.
16 |
# File 'lib/osm/grouping.rb', line 16 attribute :id, :type => Integer |
Class Method Details
.get_for_section(api, section, options = {}) ⇒ Array<Osm::Grouping>?
Get the groupings that a section has
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/osm/grouping.rb', line 36 def self.get_for_section(api, section, ={}) section_id = section.to_i cache_key = ['groupings', section_id] if ![:no_cache] && cache_exist?(api, cache_key) return cache_read(api, cache_key) end data = api.perform_query("users.php?action=getPatrols§ionid=#{section_id}") result = Array.new data['patrols'].each do |item| result.push Osm::Grouping.new({ :id => Osm::to_i_or_nil(item['patrolid']), :section_id => section_id, :name => item['name'], :active => (item['active'] == 1), :points => Osm::to_i_or_nil(item['points']), }) end cache_write(api, cache_key, result) return result end |