Class: ListStrategy
- Inherits:
-
Object
- Object
- ListStrategy
- Defined in:
- lib/list_strategy.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#month ⇒ Object
readonly
Returns the value of attribute month.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(date, month, year) ⇒ ListStrategy
constructor
A new instance of ListStrategy.
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
#date ⇒ Object (readonly)
Returns the value of attribute date.
6 7 8 |
# File 'lib/list_strategy.rb', line 6 def date @date end |
#month ⇒ Object (readonly)
Returns the value of attribute month.
6 7 8 |
# File 'lib/list_strategy.rb', line 6 def month @month end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
6 7 8 |
# File 'lib/list_strategy.rb', line 6 def year @year end |
Instance Method Details
#execute ⇒ Object
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 |