Sha256: f4bee7833ac123073ceb2194f312d0a47f1fcf8a7168ce1d3da99b55857e2291

Contents?: true

Size: 715 Bytes

Versions: 4

Compression:

Stored size: 715 Bytes

Contents

require 'virtus'

require 'vedeu/models/colour'
require 'vedeu/models/style'

module Vedeu
  class Stream
    include Virtus.model

    attribute :colour, Colour,  default: Colour.new
    attribute :style,  Style,   default: ''
    attribute :text,   String,  default: ''
    attribute :width,  Integer
    attribute :align,  Symbol,  default: :left # :centre, :right

    def to_s(options = {})
      if width
        aligned = case align
        when :left   then text.ljust(width,  ' ')
        when :right  then text.rjust(width,  ' ')
        when :centre then text.center(width, ' ')
        end

        [colour, style, aligned].join
      else
        [colour, style, text].join
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vedeu-0.1.7 lib/vedeu/models/stream.rb
vedeu-0.1.6 lib/vedeu/models/stream.rb
vedeu-0.1.5 lib/vedeu/models/stream.rb
vedeu-0.1.4 lib/vedeu/models/stream.rb