Method: Aef::Weekling::Week#until_index

Defined in:
lib/aef/weekling/week.rb

#until_index(end_index) ⇒ Range<Aef::Weekling::Week>

Returns a range of weeks beginning with self and ending with the first following week with the given index.

Examples:

End index higher than start index

Aef::Weekling::Week.new(2012, 35).until_index(50)
# => #<Aef::Weekling::Week: 2012-W35>..#<Aef::Weekling::Week: 2012-W50>

End index lower or equal than start index

Aef::Weekling::Week.new(2012, 35).until_index(11)
# => #<Aef::Weekling::Week: 2012-W35>..#<Aef::Weekling::Week:2013-W11>

Parameters:

  • end_index (Integer)

    the number of the last week in the result

Returns:

  • (Range<Aef::Weekling::Week>)

    range from self to the first following week with the given index



275
276
277
278
279
280
281
# File 'lib/aef/weekling/week.rb', line 275

def until_index(end_index)
  if end_index <= index
    self .. self.class.new(year.next, end_index)
  else
    self .. self.class.new(year, end_index)
  end
end