Class: Uptrends::Probe
- Inherits:
-
Object
- Object
- Uptrends::Probe
- Defined in:
- lib/uptrends/probe.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#checkfrequency ⇒ Object
Returns the value of attribute checkfrequency.
-
#checkpoints ⇒ Object
Returns the value of attribute checkpoints.
-
#dnslookupmode ⇒ Object
Returns the value of attribute dnslookupmode.
-
#erroronlimit1 ⇒ Object
Returns the value of attribute erroronlimit1.
-
#erroronlimit2 ⇒ Object
Returns the value of attribute erroronlimit2.
-
#erroronminbytes ⇒ Object
Returns the value of attribute erroronminbytes.
-
#generatealert ⇒ Object
Returns the value of attribute generatealert.
-
#guid ⇒ Object
readonly
Returns the value of attribute guid.
-
#httpmethod ⇒ Object
Returns the value of attribute httpmethod.
-
#isactive ⇒ Object
Returns the value of attribute isactive.
-
#iscompetitor ⇒ Object
Returns the value of attribute iscompetitor.
-
#matchpattern ⇒ Object
Returns the value of attribute matchpattern.
-
#minbytes ⇒ Object
Returns the value of attribute minbytes.
-
#name ⇒ Object
Returns the value of attribute name.
-
#notes ⇒ Object
Returns the value of attribute notes.
-
#original_hash ⇒ Object
readonly
Returns the value of attribute original_hash.
-
#original_keys ⇒ Object
readonly
Returns the value of attribute original_keys.
-
#password ⇒ Object
Returns the value of attribute password.
-
#performancelimit1 ⇒ Object
Returns the value of attribute performancelimit1.
-
#performancelimit2 ⇒ Object
Returns the value of attribute performancelimit2.
-
#port ⇒ Object
Returns the value of attribute port.
-
#postdata ⇒ Object
Returns the value of attribute postdata.
-
#probetype ⇒ Object
(also: #type)
Returns the value of attribute probetype.
-
#tcpconnecttimeout ⇒ Object
Returns the value of attribute tcpconnecttimeout.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#url ⇒ Object
Returns the value of attribute url.
-
#useragent ⇒ Object
Returns the value of attribute useragent.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #gen_request_body ⇒ Object
-
#initialize(probe_hash = {}) ⇒ Probe
constructor
A new instance of Probe.
- #to_s ⇒ Object
Constructor Details
#initialize(probe_hash = {}) ⇒ Probe
Returns a new instance of Probe.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/uptrends/probe.rb', line 8 def initialize(probe_hash = {}) @original_hash = probe_hash @original_keys = probe_hash.keys @attributes = probe_hash.keys.map{|x| x.downcase.to_sym } @guid = probe_hash["Guid"] ? probe_hash["Guid"] : nil @name = probe_hash["Name"] ? probe_hash["Name"] : nil @url = probe_hash["URL"] ? probe_hash["URL"] : nil @port = probe_hash["Port"] ? probe_hash["Port"] : nil @checkfrequency = probe_hash["CheckFrequency"] ? probe_hash["CheckFrequency"] : nil @probetype = probe_hash["ProbeType"] ? probe_hash["ProbeType"] : nil @isactive = probe_hash["IsActive"] ? probe_hash["IsActive"] : nil @generatealert = probe_hash["GenerateAlert"] ? probe_hash["GenerateAlert"] : nil @notes = probe_hash["Notes"] ? probe_hash["Notes"] : nil @performancelimit1 = probe_hash["PerformanceLimit1"] ? probe_hash["PerformanceLimit1"] : nil @performancelimit2 = probe_hash["PerformanceLimit2"] ? probe_hash["PerformanceLimit2"] : nil @erroronlimit1 = probe_hash["ErrorOnLimit1"] ? probe_hash["ErrorOnLimit1"] : nil @erroronlimit2 = probe_hash["ErrorOnLimit2"] ? probe_hash["ErrorOnLimit2"] : nil @minbytes = probe_hash["MinBytes"] ? probe_hash["MinBytes"] : nil @erroronminbytes = probe_hash["ErrorOnMinBytes"] ? probe_hash["ErrorOnMinBytes"] : nil @timeout = probe_hash["Timeout"] ? probe_hash["Timeout"] : nil @tcpconnecttimeout = probe_hash["TcpConnectTimeout"] ? probe_hash["TcpConnectTimeout"] : nil @matchpattern = probe_hash["MatchPattern"] ? probe_hash["MatchPattern"] : nil @dnslookupmode = probe_hash["DnsLookupMode"] ? probe_hash["DnsLookupMode"] : nil @useragent = probe_hash["UserAgent"] ? probe_hash["UserAgent"] : nil @username = probe_hash["UserName"] ? probe_hash["UserName"] : nil @password = probe_hash["Password"] ? probe_hash["Password"] : nil @iscompetitor = probe_hash["IsCompetitor"] ? probe_hash["IsCompetitor"] : nil @checkpoints = probe_hash["Checkpoints"] ? probe_hash["Checkpoints"] : nil if probetype == "Http" @httpmethod = probe_hash["HttpMethod"] @postdata = probe_hash["PostData"] end end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/uptrends/probe.rb', line 5 def attributes @attributes end |
#checkfrequency ⇒ Object
Returns the value of attribute checkfrequency.
6 7 8 |
# File 'lib/uptrends/probe.rb', line 6 def checkfrequency @checkfrequency end |
#checkpoints ⇒ Object
Returns the value of attribute checkpoints.
6 7 8 |
# File 'lib/uptrends/probe.rb', line 6 def checkpoints @checkpoints end |
#dnslookupmode ⇒ Object
Returns the value of attribute dnslookupmode.
6 7 8 |
# File 'lib/uptrends/probe.rb', line 6 def dnslookupmode @dnslookupmode end |
#erroronlimit1 ⇒ Object
Returns the value of attribute erroronlimit1.
6 7 8 |
# File 'lib/uptrends/probe.rb', line 6 def erroronlimit1 @erroronlimit1 end |
#erroronlimit2 ⇒ Object
Returns the value of attribute erroronlimit2.
6 7 8 |
# File 'lib/uptrends/probe.rb', line 6 def erroronlimit2 @erroronlimit2 end |
#erroronminbytes ⇒ Object
Returns the value of attribute erroronminbytes.
6 7 8 |
# File 'lib/uptrends/probe.rb', line 6 def erroronminbytes @erroronminbytes end |
#generatealert ⇒ Object
Returns the value of attribute generatealert.
6 7 8 |
# File 'lib/uptrends/probe.rb', line 6 def generatealert @generatealert end |
#guid ⇒ Object (readonly)
Returns the value of attribute guid.
5 6 7 |
# File 'lib/uptrends/probe.rb', line 5 def guid @guid end |
#httpmethod ⇒ Object
Returns the value of attribute httpmethod.
6 7 8 |
# File 'lib/uptrends/probe.rb', line 6 def httpmethod @httpmethod end |
#isactive ⇒ Object
Returns the value of attribute isactive.
6 7 8 |
# File 'lib/uptrends/probe.rb', line 6 def isactive @isactive end |
#iscompetitor ⇒ Object
Returns the value of attribute iscompetitor.
6 7 8 |
# File 'lib/uptrends/probe.rb', line 6 def iscompetitor @iscompetitor end |
#matchpattern ⇒ Object
Returns the value of attribute matchpattern.
6 7 8 |
# File 'lib/uptrends/probe.rb', line 6 def matchpattern @matchpattern end |
#minbytes ⇒ Object
Returns the value of attribute minbytes.
6 7 8 |
# File 'lib/uptrends/probe.rb', line 6 def minbytes @minbytes end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/uptrends/probe.rb', line 6 def name @name end |
#notes ⇒ Object
Returns the value of attribute notes.
6 7 8 |
# File 'lib/uptrends/probe.rb', line 6 def notes @notes end |
#original_hash ⇒ Object (readonly)
Returns the value of attribute original_hash.
5 6 7 |
# File 'lib/uptrends/probe.rb', line 5 def original_hash @original_hash end |
#original_keys ⇒ Object (readonly)
Returns the value of attribute original_keys.
5 6 7 |
# File 'lib/uptrends/probe.rb', line 5 def original_keys @original_keys end |
#password ⇒ Object
Returns the value of attribute password.
6 7 8 |
# File 'lib/uptrends/probe.rb', line 6 def password @password end |
#performancelimit1 ⇒ Object
Returns the value of attribute performancelimit1.
6 7 8 |
# File 'lib/uptrends/probe.rb', line 6 def performancelimit1 @performancelimit1 end |
#performancelimit2 ⇒ Object
Returns the value of attribute performancelimit2.
6 7 8 |
# File 'lib/uptrends/probe.rb', line 6 def performancelimit2 @performancelimit2 end |
#port ⇒ Object
Returns the value of attribute port.
6 7 8 |
# File 'lib/uptrends/probe.rb', line 6 def port @port end |
#postdata ⇒ Object
Returns the value of attribute postdata.
6 7 8 |
# File 'lib/uptrends/probe.rb', line 6 def postdata @postdata end |
#probetype ⇒ Object Also known as: type
Returns the value of attribute probetype.
6 7 8 |
# File 'lib/uptrends/probe.rb', line 6 def probetype @probetype end |
#tcpconnecttimeout ⇒ Object
Returns the value of attribute tcpconnecttimeout.
6 7 8 |
# File 'lib/uptrends/probe.rb', line 6 def tcpconnecttimeout @tcpconnecttimeout end |
#timeout ⇒ Object
Returns the value of attribute timeout.
6 7 8 |
# File 'lib/uptrends/probe.rb', line 6 def timeout @timeout end |
#url ⇒ Object
Returns the value of attribute url.
6 7 8 |
# File 'lib/uptrends/probe.rb', line 6 def url @url end |
#useragent ⇒ Object
Returns the value of attribute useragent.
6 7 8 |
# File 'lib/uptrends/probe.rb', line 6 def useragent @useragent end |
#username ⇒ Object
Returns the value of attribute username.
6 7 8 |
# File 'lib/uptrends/probe.rb', line 6 def username @username end |
Instance Method Details
#gen_request_body ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/uptrends/probe.rb', line 47 def gen_request_body new_hash = original_keys.inject({}) do |memo,key| if key == 'Guid' memo else memo[key] = self.send(key.downcase.to_sym) memo end end request_body = JSON.dump(new_hash) end |
#to_s ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/uptrends/probe.rb', line 60 def to_s string = [] original_keys.each do |key| string << "#{key}: #{self.send(key.downcase.to_sym)}" end "#{string.join("\n")}" end |