Class: Poly::Trimester

Inherits:
Object
  • Object
show all
Defined in:
lib/polyhoraire/trimester.rb

Constant Summary collapse

DAY_RANGE =
(1..5)
WEEK_RANGE =
(1..2)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#startsObject (readonly)

Returns the value of attribute starts.



5
6
7
# File 'lib/polyhoraire/trimester.rb', line 5

def starts
  @starts
end

#weekObject (readonly)

Returns the value of attribute week.



5
6
7
# File 'lib/polyhoraire/trimester.rb', line 5

def week
  @week
end

Class Method Details

.fromYAML(trimesterID) ⇒ Object

Create from a YAML file wich is situated in ‘conf/trimesters.yaml’

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/polyhoraire/trimester.rb', line 11

def self.fromYAML(trimesterID)
  config = YAML.load_file(Poly::userConfDir + "/trimesters.yaml")
  raise ArgumentError, "Invalid trimester : " + trimesterID.to_s unless config.include?(trimesterID)
  selected = config[trimesterID]
  
  
  starts      = selected['starts']
  schoolBreak = selected['schoolBreak']
  ends        = selected['ends']
  holidays    = selected['holidays']
  exceptions  = selected['exceptions']
  
  return self.new(starts, schoolBreak, ends, holidays, exceptions)
end

Instance Method Details

#getDates(period) ⇒ Object

period : Period object for wich you want every dates it occurs Returns the list of dates for the course period



28
29
30
31
32
33
34
# File 'lib/polyhoraire/trimester.rb', line 28

def getDates(period)
  if period.week == 0
    dates = @week[1][period.weekDay] + @week[2][period.weekDay] 
    return dates.sort
  end
  return @week[period.week][period.weekDay].sort
end