Class: SaveTheMonth::ExpectedAmountQuery

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(balance) ⇒ ExpectedAmountQuery

Returns a new instance of ExpectedAmountQuery.



5
6
7
# File 'lib/query_dsl.rb', line 5

def initialize(balance)
  self.balance = balance
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



3
4
5
# File 'lib/query_dsl.rb', line 3

def amount
  @amount
end

#balanceObject

Returns the value of attribute balance.



3
4
5
# File 'lib/query_dsl.rb', line 3

def balance
  @balance
end

Instance Method Details

#at_beginningObject



9
10
11
# File 'lib/query_dsl.rb', line 9

def at_beginning
  balance.initial_amount
end

#at_date(boundary_date) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/query_dsl.rb', line 21

def at_date(boundary_date)
  self.amount = balance.initial_amount
  
  (balance.initial_date..boundary_date).each do |date|
    update_with_day(date)
  end
  
  self.amount
end

#at_endObject



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

def at_end
  at_date balance.final_date
end

#todayObject



13
14
15
# File 'lib/query_dsl.rb', line 13

def today
  at_date Date.new
end