Class: Focuslight::ComplexGraph
Instance Attribute Summary collapse
-
#complex_graph ⇒ Object
readonly
Returns the value of attribute complex_graph.
-
#data_rows ⇒ Object
Returns the value of attribute data_rows.
-
#sumup ⇒ Object
Returns the value of attribute sumup.
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) ⇒ ComplexGraph
constructor
A new instance of ComplexGraph.
- #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) ⇒ ComplexGraph
Returns a new instance of ComplexGraph.
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/focuslight/graph.rb', line 172 def initialize(row) super uri = [:'type-1', :'path-1'].map{|k| @parsed_meta[k]}.join(':') + ':0' # stack data_rows = [] first_row = { type: @parsed_meta[:'type-1'], path: @parsed_meta[:'path-1'].to_i, stack: false, graph_id: @parsed_meta[:'path-1'].to_i, } data_rows << first_row unless @parsed_meta[:'type-2'].is_a?(Array) [:'type-2', :'path-2', :'stack-2'].each do |key| @parsed_meta[key] = [@parsed_meta[key]].flatten end end @parsed_meta[:'type-2'].each_with_index do |type, i| t = @parsed_meta[:'type-2'][i] p = @parsed_meta[:'path-2'][i].to_i s = @parsed_meta[:'stack-2'][i].is_a?(String) ? !!(@parsed_meta[:'stack-2'][i] =~ /^(1|true)$/i) : !!@parsed_meta[:'stack-2'][i] uri += ':' + [t, p, (s ? '1' : '0')].join(':') data_rows << {type: t, path: p, stack: s, graph_id: p} end @sumup = @parsed_meta.fetch(:sumup, '0') != '0' # '0' is false @data_rows = data_rows @complex_graph = uri end |
Instance Attribute Details
#complex_graph ⇒ Object (readonly)
Returns the value of attribute complex_graph.
170 171 172 |
# File 'lib/focuslight/graph.rb', line 170 def complex_graph @complex_graph end |
#data_rows ⇒ Object
Returns the value of attribute data_rows.
169 170 171 |
# File 'lib/focuslight/graph.rb', line 169 def data_rows @data_rows end |
#sumup ⇒ Object
Returns the value of attribute sumup.
169 170 171 |
# File 'lib/focuslight/graph.rb', line 169 def sumup @sumup end |
Class Method Details
.meta_clean(args = {}) ⇒ Object
234 235 236 237 238 |
# File 'lib/focuslight/graph.rb', line 234 def self.(args={}) args.delete_if do |k,v| %w(id service_name section_name graph_name number description sort).include?(k.to_s) end end |
Instance Method Details
#complex? ⇒ Boolean
215 216 217 |
# File 'lib/focuslight/graph.rb', line 215 def complex? true end |
#to_hash ⇒ Object
206 207 208 209 210 211 212 213 |
# File 'lib/focuslight/graph.rb', line 206 def to_hash complex = { sumup: @sumup, data: @data_rows, complex: true } hash = super hash.merge(complex) end |
#update(args = {}) ⇒ Object
219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/focuslight/graph.rb', line 219 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 else [k.to_sym] = v end end @parsed_meta = self.class.(@parsed_meta.merge()) @meta = @parsed_meta.to_json end |