Class: Osm::Register::Attendance

Inherits:
Model
  • Object
show all
Defined in:
lib/osm/register.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#<, #<=, #>, #>=, #between?, #changed_attributes, configure, #reset_changed_attributes, #to_i

Constructor Details

#initializeObject

Initialize a new registerData


# File 'lib/osm/register.rb', line 208

Instance Attribute Details

#attendanceHash


186
# File 'lib/osm/register.rb', line 186

attribute :member_id, :type => Integer

#first_nameString


186
# File 'lib/osm/register.rb', line 186

attribute :member_id, :type => Integer

#grouping_idFixnum


186
# File 'lib/osm/register.rb', line 186

attribute :member_id, :type => Integer

#last_nameString


186
# File 'lib/osm/register.rb', line 186

attribute :member_id, :type => Integer

#member_idFixnum


186
# File 'lib/osm/register.rb', line 186

attribute :member_id, :type => Integer

#section_idFixnum


186
# File 'lib/osm/register.rb', line 186

attribute :member_id, :type => Integer

#totalFixNum


186
# File 'lib/osm/register.rb', line 186

attribute :member_id, :type => Integer

Instance Method Details

#<=>(another) ⇒ Object

Compare Attendance based on section_id, grouping_id, last_name then first_name


229
230
231
232
233
234
235
# File 'lib/osm/register.rb', line 229

def <=>(another)
  result = self.section_id <=> another.try(:section_id)
  result = self.grouping_id <=> another.try(:grouping_id) if result == 0
  result = self.last_name <=> another.try(:last_name) if result == 0
  result = self.first_name <=> another.try(:last_name) if result == 0
  return result
end

#absent_on?(date) ⇒ Boolean

Find out if the member was absent on a date


223
224
225
# File 'lib/osm/register.rb', line 223

def absent_on?(date)
  attendance[date] != :yes
end

#present_on?(date) ⇒ Boolean

Find out if the member was present on a date


216
217
218
# File 'lib/osm/register.rb', line 216

def present_on?(date)
  attendance[date] == :yes
end