Module: DateDiscreter

Defined in:
lib/date_discreter.rb,
lib/date_discreter/version.rb

Constant Summary collapse

VERSION =
"0.0.4"

Class Method Summary collapse

Class Method Details

.continuous_days?(dates) ⇒ Boolean

whether arg months are continuous

Parameters:

  • dates (Array<Date>)

Returns:

  • (Boolean)


50
51
52
# File 'lib/date_discreter.rb', line 50

def continuous_days?(dates)
  discrete_days(dates).empty?
end

.continuous_hours?(hours) ⇒ Boolean

whether arg months are continuous

Parameters:

  • hours (Array<Date>)

Returns:

  • (Boolean)


56
57
58
# File 'lib/date_discreter.rb', line 56

def continuous_hours?(hours)
  discrete_hours(hours).empty?
end

.continuous_months?(months) ⇒ Boolean

whether arg months are continuous

Parameters:

  • months (Array<Date>)

Returns:

  • (Boolean)


44
45
46
# File 'lib/date_discreter.rb', line 44

def continuous_months?(months)
  discrete_months(months).empty?
end

.discrete_days(dates) ⇒ Array<Date>

return discrete of arg days

Parameters:

  • dates (Array<Date,Time>)

Returns:

  • (Array<Date>)

    if arg is continuous return empty array.



17
18
19
# File 'lib/date_discreter.rb', line 17

def discrete_days(dates)
  discrete_times(dates, 1.day)
end

.discrete_hours(hours) ⇒ Array<Time>

return discrete of arg hours

Parameters:

  • hours (Array<Time>)

Returns:

  • (Array<Time>)

    if arg is continuous return empty array.



24
25
26
# File 'lib/date_discreter.rb', line 24

def discrete_hours(hours)
  discrete_times(hours, 1.hour)
end

.discrete_months(months) ⇒ Array<Date>

return discrete of arg months

Parameters:

  • months (Array<Date,Time>)

Returns:

  • (Array<Date>)

    if arg is continuous return empty array.



10
11
12
# File 'lib/date_discreter.rb', line 10

def discrete_months(months)
  discrete_times(months, 1.month)
end