Class: Updown::Check

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Check



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/updown/check.rb', line 15

def initialize(json)
  @token         = json['token']
  @url           = json['url']
  @last_status   = json['last_status']
  @enabled       = json['enabled']
  @period        = json['period']
  @apdex_t       = json['apdex_t']
  @published     = json['published']
  @uptime        = json['uptime']
  @down          = json['down']
  @error         = json['error']
  @down_since    = Time.parse(json['down_since']) if json['down_since']
  @last_check_at = Time.parse(json['last_check_at']) if json['last_check_at']
  @next_check_at = Time.parse(json['next_check_at']) if json['next_check_at']
  if ssl = json['ssl']
    @ssl_tested_at = Time.parse(ssl['tested_at']) if ssl['tested_at']
    @ssl_valid     = ssl['valid']
    @ssl_error     = ssl['error']
  end
end

Instance Attribute Details

#apdex_tObject

Returns the value of attribute apdex_t.



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

def apdex_t
  @apdex_t
end

#downObject

Returns the value of attribute down.



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

def down
  @down
end

#down_sinceObject

Returns the value of attribute down_since.



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

def down_since
  @down_since
end

#enabledObject

Returns the value of attribute enabled.



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

def enabled
  @enabled
end

#errorObject

Returns the value of attribute error.



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

def error
  @error
end

#last_check_atObject

Returns the value of attribute last_check_at.



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

def last_check_at
  @last_check_at
end

#last_statusObject

Returns the value of attribute last_status.



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

def last_status
  @last_status
end

#next_check_atObject

Returns the value of attribute next_check_at.



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

def next_check_at
  @next_check_at
end

#periodObject

Returns the value of attribute period.



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

def period
  @period
end

#publishedObject

Returns the value of attribute published.



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

def published
  @published
end

#ssl_errorObject

Returns the value of attribute ssl_error.



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

def ssl_error
  @ssl_error
end

#ssl_tested_atObject

Returns the value of attribute ssl_tested_at.



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

def ssl_tested_at
  @ssl_tested_at
end

#ssl_validObject

Returns the value of attribute ssl_valid.



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

def ssl_valid
  @ssl_valid
end

#tokenObject

Returns the value of attribute token.



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

def token
  @token
end

#uptimeObject

Returns the value of attribute uptime.



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

def uptime
  @uptime
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end

Class Method Details

.allObject



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

def self.all
  Updown::Call.checks.map do |check|
    Check.new check
  end
end

.create(url, attributes = {}) ⇒ Object



11
12
13
# File 'lib/updown/check.rb', line 11

def self.create(url, attributes = {})
  Check.new Updown::Call.create_check(attributes.merge(url: url))
end

Instance Method Details

#destroyObject



44
45
46
# File 'lib/updown/check.rb', line 44

def destroy
  Updown::Call.destroy_check(@token)['deleted']
end

#downtimes(page: 1) ⇒ Object



36
37
38
# File 'lib/updown/check.rb', line 36

def downtimes page: 1
  Downtime.find(@token, page: page)
end

#update(attributes = {}) ⇒ Object



40
41
42
# File 'lib/updown/check.rb', line 40

def update(attributes={})
  Check.new Updown::Call.update_check(@token, attributes)
end