Class: YuiRestClient::Widgets::Bargraph

Inherits:
Base
  • Object
show all
Defined in:
lib/yui_rest_client/widgets/bargraph.rb

Overview

Class representing a bar graph in the UI, namely YBarGraph.

Instance Method Summary collapse

Methods inherited from Base

#action, #collect_all, #debug_label, #enabled?, #exists?, #initialize, #property

Methods included from YuiRestClient::Waitable

#wait_until, #wait_while

Constructor Details

This class inherits a constructor from YuiRestClient::Widgets::Base

Instance Method Details

#labelsArray

Returns the labels list of all segments in the bar graph.

Examples:

Get labels of the segments in the bargraph with id “test_id”

app.bargraph(id: 'test_id').labels

Returns:

  • (Array)

    array of labels in order they are stored in segments hash.



48
49
50
# File 'lib/yui_rest_client/widgets/bargraph.rb', line 48

def labels
  segments.map { |segment| segment[:label] }
end

#segmentsArray

Returns the list of segments in the bar graph. Each segment is defined by label and value. Segment length is defined by proportional ratio of the segment value. For instance, if segment values are 100, 200, 700: it means first segment will take 100/1000=10%, second 20% and third one 70% accordingly. {

"class" : "YBarGraph",
"id" : "test_id",
"segments" :
[
  {
    "label" : "Windows\nused\n%1 MB",
    "value" : 600
  },
  {
    "label" : "Windows\nfree\n%1 MB",
    "value" : 350
  },
  {
    "label" : "Linux\n%1 MB",
    "value" : 800
  }
],

}

Examples:

Get segments from the bargraph with id “test_id”

app.bargraph(id: 'test_id').segments
app.bargraph(id: 'test_id').segments[1][:value]
app.bargraph(id: 'test_id').segments[1][:label]

Returns:

  • (Array)

    array of [Hash] objects with :label and :value keys which store label and segment value for given segment



39
40
41
# File 'lib/yui_rest_client/widgets/bargraph.rb', line 39

def segments
  property(:segments)
end

#valuesArray

Returns the values list of all segments in the bar graph.

Examples:

Get values of the segments in the bargraph with id “test_id”

app.bargraph(id: 'test_id').values

Returns:

  • (Array)

    array of values in order they are stored in segments hash.



57
58
59
# File 'lib/yui_rest_client/widgets/bargraph.rb', line 57

def values
  segments.map { |segment| segment[:value] }
end