Class: Uptrends::ProbeGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/uptrends/probe_group.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(probe_group_hash = {}) ⇒ ProbeGroup

Returns a new instance of ProbeGroup.



10
11
12
13
14
15
16
17
18
19
# File 'lib/uptrends/probe_group.rb', line 10

def initialize(probe_group_hash = {})
  @original_hash     = probe_group_hash
  @original_keys     = probe_group_hash.keys
  @attributes        = probe_group_hash.keys.map{|x| x.downcase.to_sym }

  @guid               = probe_group_hash["Guid"] ? probe_group_hash["Guid"] : nil
  @name               = probe_group_hash["Name"]
  @isall              = probe_group_hash["IsAll"]
  @isclientprobegroup = probe_group_hash["IsClientProbeGroup"]
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/uptrends/probe_group.rb', line 5

def attributes
  @attributes
end

#guidObject (readonly)

Returns the value of attribute guid.



7
8
9
# File 'lib/uptrends/probe_group.rb', line 7

def guid
  @guid
end

#isallObject (readonly)

Returns the value of attribute isall.



7
8
9
# File 'lib/uptrends/probe_group.rb', line 7

def isall
  @isall
end

#isclientprobegroupObject (readonly)

Returns the value of attribute isclientprobegroup.



7
8
9
# File 'lib/uptrends/probe_group.rb', line 7

def isclientprobegroup
  @isclientprobegroup
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/uptrends/probe_group.rb', line 8

def name
  @name
end

#original_hashObject (readonly)

Returns the value of attribute original_hash.



5
6
7
# File 'lib/uptrends/probe_group.rb', line 5

def original_hash
  @original_hash
end

#original_keysObject (readonly)

Returns the value of attribute original_keys.



5
6
7
# File 'lib/uptrends/probe_group.rb', line 5

def original_keys
  @original_keys
end

Instance Method Details

#gen_request_bodyObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/uptrends/probe_group.rb', line 21

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_sObject



34
35
36
37
38
39
40
41
# File 'lib/uptrends/probe_group.rb', line 34

def to_s
  string = []
  original_keys.each do |key|
    string << "#{key}: #{self.send(key.downcase.to_sym)}"
  end

  "#{string.join("\n")}"
end