Class: Prosperity::Period

Inherits:
Struct
  • Object
show all
Defined in:
lib/prosperity/period.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ceil_dateObject

Returns the value of attribute ceil_date

Returns:

  • (Object)

    the current value of ceil_date



2
3
4
# File 'lib/prosperity/period.rb', line 2

def ceil_date
  @ceil_date
end

#db_strf_strObject

Returns the value of attribute db_strf_str

Returns:

  • (Object)

    the current value of db_strf_str



2
3
4
# File 'lib/prosperity/period.rb', line 2

def db_strf_str
  @db_strf_str
end

#durationObject

Returns the value of attribute duration

Returns:

  • (Object)

    the current value of duration



2
3
4
# File 'lib/prosperity/period.rb', line 2

def duration
  @duration
end

#floor_dateObject

Returns the value of attribute floor_date

Returns:

  • (Object)

    the current value of floor_date



2
3
4
# File 'lib/prosperity/period.rb', line 2

def floor_date
  @floor_date
end

#ruby_strf_strObject

Returns the value of attribute ruby_strf_str

Returns:

  • (Object)

    the current value of ruby_strf_str



2
3
4
# File 'lib/prosperity/period.rb', line 2

def ruby_strf_str
  @ruby_strf_str
end

Instance Method Details

#actual_end_time(end_time) ⇒ Object



16
17
18
# File 'lib/prosperity/period.rb', line 16

def actual_end_time(end_time)
  ceil_date.call(end_time) + 1
end

#actual_start_time(start_time) ⇒ Object



12
13
14
# File 'lib/prosperity/period.rb', line 12

def actual_start_time(start_time)
  floor_date.call(start_time)
end

#each_period(start_time, end_time) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/prosperity/period.rb', line 3

def each_period(start_time, end_time)
  start_time = actual_start_time(start_time)
  end_time = actual_end_time(end_time) + 1
  while start_time <= end_time
    yield start_time
    start_time += duration
  end
end