Class: Updown::Downtime

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Downtime

Returns a new instance of Downtime.



11
12
13
14
15
16
# File 'lib/updown/downtime.rb', line 11

def initialize(json)
  @error      = json['error']
  @started_at = Time.parse(json['started_at']) if json['started_at']
  @ended_at   = Time.parse(json['ended_at']) if json['ended_at']
  @duration   = json['duration']
end

Instance Attribute Details

#durationObject

Returns the value of attribute duration.



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

def duration
  @duration
end

#ended_atObject

Returns the value of attribute ended_at.



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

def ended_at
  @ended_at
end

#errorObject

Returns the value of attribute error.



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

def error
  @error
end

#started_atObject

Returns the value of attribute started_at.



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

def started_at
  @started_at
end

Class Method Details

.find(token, page: 1) ⇒ Object



5
6
7
8
9
# File 'lib/updown/downtime.rb', line 5

def self.find(token, page: 1)
  Updown::Call.downtimes(token, page: page).map do |downtime|
    Downtime.new downtime
  end
end