Class: Focuslight::SimpleGraph
Constant Summary collapse
- COLUMNS =
%w(service_name section_name graph_name number mode color llimit created_at updated_at)
- PLACEHOLDERS =
COLUMNS.map{|c| '?'}
Instance Attribute Summary collapse
-
#adjust ⇒ Object
Returns the value of attribute adjust.
-
#adjustval ⇒ Object
Returns the value of attribute adjustval.
-
#color ⇒ Object
Returns the value of attribute color.
-
#llimit ⇒ Object
Returns the value of attribute llimit.
-
#md5 ⇒ Object
readonly
Returns the value of attribute md5.
-
#mode ⇒ Object
Returns the value of attribute mode.
-
#type ⇒ Object
Returns the value of attribute type.
-
#ulimit ⇒ Object
Returns the value of attribute ulimit.
-
#unit ⇒ Object
Returns the value of attribute unit.
Attributes inherited from Graph
#c_type, #created_at_time, #description, #graph, #id, #meta, #number, #section, #service, #sort, #stack, #updated_at_time
Class Method Summary collapse
Instance Method Summary collapse
- #complex? ⇒ Boolean
-
#initialize(row) ⇒ SimpleGraph
constructor
A new instance of SimpleGraph.
- #to_hash ⇒ Object
- #update(args = {}) ⇒ Object
Methods inherited from Graph
concrete, #created_at, hash2request, #path, #updated_at
Methods included from Logger
Constructor Details
#initialize(row) ⇒ SimpleGraph
Returns a new instance of SimpleGraph.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/focuslight/graph.rb', line 107 def initialize(row) super @mode = row[:mode] || 'gauge' # NOT NULL DEFAULT 'gauge' @color = row[:color] || '#00CC00' # NOT NULL DEFAULT '#00CC00' @ulimit = row[:ulimit] || 1000000000000000 # NOT NULL DEFAULT 1000000000000000 @llimit = row[:llimit] || 0 @type = row[:type] || 'AREA' @md5 = Digest::MD5.hexdigest(@id.to_s) @adjust = @parsed_meta.fetch(:adjust, '*') @adjustval = @parsed_meta.fetch(:adjustval, '1') @unit = @parsed_meta.fetch(:unit, '') end |
Instance Attribute Details
#adjust ⇒ Object
Returns the value of attribute adjust.
105 106 107 |
# File 'lib/focuslight/graph.rb', line 105 def adjust @adjust end |
#adjustval ⇒ Object
Returns the value of attribute adjustval.
105 106 107 |
# File 'lib/focuslight/graph.rb', line 105 def adjustval @adjustval end |
#color ⇒ Object
Returns the value of attribute color.
102 103 104 |
# File 'lib/focuslight/graph.rb', line 102 def color @color end |
#llimit ⇒ Object
Returns the value of attribute llimit.
102 103 104 |
# File 'lib/focuslight/graph.rb', line 102 def llimit @llimit end |
#md5 ⇒ Object (readonly)
Returns the value of attribute md5.
104 105 106 |
# File 'lib/focuslight/graph.rb', line 104 def md5 @md5 end |
#mode ⇒ Object
Returns the value of attribute mode.
102 103 104 |
# File 'lib/focuslight/graph.rb', line 102 def mode @mode end |
#type ⇒ Object
Returns the value of attribute type.
102 103 104 |
# File 'lib/focuslight/graph.rb', line 102 def type @type end |
#ulimit ⇒ Object
Returns the value of attribute ulimit.
102 103 104 |
# File 'lib/focuslight/graph.rb', line 102 def ulimit @ulimit end |
#unit ⇒ Object
Returns the value of attribute unit.
105 106 107 |
# File 'lib/focuslight/graph.rb', line 105 def unit @unit end |
Class Method Details
.meta_clean(args = {}) ⇒ Object
160 161 162 163 164 165 |
# File 'lib/focuslight/graph.rb', line 160 def self.(args={}) args.delete_if do |k,v| %w(id service_name section_name graph_name number description sort mode color ulimit llimit type).include?(k.to_s) end end |
Instance Method Details
#complex? ⇒ Boolean
136 137 138 |
# File 'lib/focuslight/graph.rb', line 136 def complex? false end |
#to_hash ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/focuslight/graph.rb', line 123 def to_hash simple = { mode: @mode, color: @color, ulimit: @ulimit, llimit: @llimit, type: @type, adjust: @adjust, adjustval: @adjustval, unit: @unit, complex: false, md5: @md5, meta: @meta, } hash = super hash.merge(simple) end |
#update(args = {}) ⇒ Object
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/focuslight/graph.rb', line 140 def update(args={}) = @parsed_meta.dup args.each do |k, v| case k.to_sym when :number then @number = v when :description then @description = v when :sort then @sort = v when :mode then @mode = v when :color then @color = v when :ulimit then @ulimit = v when :llimit then @llimit = v when :type then @type = v else [k.to_sym] = v end end @parsed_meta = self.class.(@parsed_meta.merge()) @meta = @parsed_meta.to_json end |