Method: Vedeu::DSL::Align#width

Defined in:
lib/vedeu/dsl/helpers/align.rb

#widthFixnum (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return the width given in the options. If no :width option was set, but a :name option was set, then we can use the width of the interface to determine the correct width to use. There is a caveat in this; if the :align option was set to :left, but no :width provided, then we don’t want to use the interface’s width. The reason being, is that there may be another stream in this line which will not appear by default as it will be push right out of the visible area.

Return the width of the interface when a name is given, otherwise use the given width.

Returns:

  • (Fixnum)


121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/vedeu/dsl/helpers/align.rb', line 121

def width
  if present?(options[:width])
    options[:width]

  elsif present?(options[:name])
    if left_aligned?
      value.size

    else
      geometry.bordered_width

    end

  else
    value.size

  end
end