Class: Cycle

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, number, effective, ending) ⇒ Cycle

Returns a new instance of Cycle.



6
7
8
9
10
11
# File 'lib/nacofetch/cycle.rb', line 6

def initialize(url, number, effective, ending)
  @url = url
  @number = number
  @effective = effective
  @ending = ending
end

Instance Attribute Details

#effectiveObject

Returns the value of attribute effective.



4
5
6
# File 'lib/nacofetch/cycle.rb', line 4

def effective
  @effective
end

#endingObject

Returns the value of attribute ending.



4
5
6
# File 'lib/nacofetch/cycle.rb', line 4

def ending
  @ending
end

#numberObject

Returns the value of attribute number.



4
5
6
# File 'lib/nacofetch/cycle.rb', line 4

def number
  @number
end

#urlObject

Returns the value of attribute url.



4
5
6
# File 'lib/nacofetch/cycle.rb', line 4

def url
  @url
end

Instance Method Details

#statusObject



13
14
15
16
17
18
19
# File 'lib/nacofetch/cycle.rb', line 13

def status
  now = Time.new

  return "PENDING" if now.before?@effective
  return "CURRENT" if now.before?@ending and now.after?@effective
         "EXPIRED" if now.after?@ending
end