Class: Nucleo::Models::DateRange

Inherits:
Object
  • Object
show all
Defined in:
lib/nucleo/models/date_range.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Nucleo::Models::DateRange

Returns an instance of the DateRange domain model

Parameters:

  • attributes (Hash) (defaults to: {})


9
10
11
# File 'lib/nucleo/models/date_range.rb', line 9

def initialize(attributes={})
  @attributes = attributes
end

Instance Method Details

#daysInteger

Returns the inclusive days for this range

Returns:

  • (Integer)


16
17
18
19
20
# File 'lib/nucleo/models/date_range.rb', line 16

def days
  return nil unless both_dates?

  ((self.end_date - self.start_date) + 1).to_i
end

#end_dateDate?

Returns the end date

Returns:

  • (Date, nil)


36
37
38
39
40
41
42
# File 'lib/nucleo/models/date_range.rb', line 36

def end_date
  begin
    Date.parse(end_date_value)
  rescue
    nil
  end
end

#start_dateDate?

Returns the start date

Returns:

  • (Date, nil)


25
26
27
28
29
30
31
# File 'lib/nucleo/models/date_range.rb', line 25

def start_date
  begin
    Date.parse(start_date_value)
  rescue
    nil
  end
end