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

Parameters:

  • attributes (Hash)

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


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

Instance Attribute Details

#attendanceHash

Returns The data for each field - keys are the date, values one of :yes, :unadvised_absent or :advised_absent.

Returns:

  • (Hash)

    The data for each field - keys are the date, values one of :yes, :unadvised_absent or :advised_absent


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

attribute :member_id, :type => Integer

#first_nameString

Returns The member's first name.

Returns:

  • (String)

    The member's first name


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

attribute :member_id, :type => Integer

#grouping_idFixnum

Returns The OSM ID for the member's grouping.

Returns:

  • (Fixnum)

    The OSM ID for the member's grouping


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

attribute :member_id, :type => Integer

#last_nameString

Returns The member's last name.

Returns:

  • (String)

    The member's last name


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

attribute :member_id, :type => Integer

#member_idFixnum

Returns The OSM ID for the member.

Returns:

  • (Fixnum)

    The OSM ID for the member


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

attribute :member_id, :type => Integer

#section_idFixnum

Returns The OSM ID for the member's section.

Returns:

  • (Fixnum)

    The OSM ID for the member's section


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

attribute :member_id, :type => Integer

#totalFixNum

Returns Total.

Returns:

  • (FixNum)

    Total


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

Parameters:

  • date (Date)

    The date to check attendance for

Returns:

  • (Boolean)

    whether the member was absent on the given 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

Parameters:

  • date (Date)

    The date to check attendance for

Returns:

  • (Boolean)

    whether the member was presnt on the given date


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

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