class SyncSign::Widget::ButtonLabels

A widget that draws button labels for the 4.2“ display.

Attributes

labels[RW]

@return [Array] Up to 4 strings of 17 characters each, to label the buttons with.

reversed[RW]

@return [Array] Up to 4 boolean values showing whether each button should be reverse colours.

Public Class Methods

new(labels: [], reversed: []) click to toggle source

Initialize a new Button Labels widget. @param labels [Array] Up to 4 strings of 17 characters each, to label the buttons with. @param reversed [Array] Up to 4 boolean values showing whether each button should be reverse colours (white on black). Default is black on white.

# File lib/syncsign/widgets/buttonlabels.rb, line 15
def initialize(labels: [], reversed: [])
  # TODO: validate <= 17 characters in each label
  @labels = labels
  @reversed = reversed
end

Public Instance Methods

==(other) click to toggle source
# File lib/syncsign/widgets/buttonlabels.rb, line 40
def ==(other)
  @labels == other.labels &&
  @reversed == other.reversed
end
to_a() click to toggle source

Convert the widget into an array for sending to the SyncSign service.

# File lib/syncsign/widgets/buttonlabels.rb, line 23
def to_a
  label_arr = []
  (0..3).each do |idx|
    label_arr[idx] = {
      :title => @labels[idx] || "",
      :style => @reversed[idx] || 'DISABLED'
    }
  end

  {
    'type': 'BOTTOM_CUSTOM_BUTTONS',
    'data': {
      'list': label_arr
    }
  }
end