Class: ListStrategy

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(date, month, year) ⇒ ListStrategy

Returns a new instance of ListStrategy.



8
9
10
11
12
# File 'lib/list_strategy.rb', line 8

def initialize(date, month, year)
  @date = date
  @month = month
  @year = year
end

Instance Attribute Details

#dateObject (readonly)

Returns the value of attribute date.



6
7
8
# File 'lib/list_strategy.rb', line 6

def date
  @date
end

#monthObject (readonly)

Returns the value of attribute month.



6
7
8
# File 'lib/list_strategy.rb', line 6

def month
  @month
end

#yearObject (readonly)

Returns the value of attribute year.



6
7
8
# File 'lib/list_strategy.rb', line 6

def year
  @year
end

Instance Method Details

#executeObject



14
15
16
17
18
19
20
# File 'lib/list_strategy.rb', line 14

def execute
  return list_by_month_and_year if @month && @year
  return list_by_month_current_year if @month && @year.nil?
  return list_by_year if @month.nil? && @year

  list_by_date
end