Sha256: 856e93ae8c1c42dbe57e356a203ef1ba89c25dab2c52c73cbc7d132e91792f19

Contents?: true

Size: 1.81 KB

Versions: 2

Compression:

Stored size: 1.81 KB

Contents

module Vedeu
  module API
    class Line < Vedeu::Line
      include Helpers

      # Define a stream (a subset of a line).
      #
      # @param block [Proc] Block contains directives relating to API::Stream.
      #
      # @example
      #   ...
      #     line do
      #       stream do
      #         ... other stream directives ...
      #       end
      #     end
      #   ...
      #
      # @return [Array]
      def stream(&block)
        attributes[:streams] << API::Stream.build(&block)
      end

      # Define text for a line. Using this directive will not allow stream
      # attributes for this line but is useful for adding lines straight into
      # the interface.
      #
      # @param value [String]
      #
      # @example
      #   ...
      #     line do
      #       text 'Some text to display...'
      #
      # @return [Array]
      def text(value)
        attributes[:streams] << { text: value }
      end

      # @param value [String]
      # @param block [Proc]
      #
      # @example
      #   ...
      #     line do
      #       foreground '#00ff00' do
      #         ... other stream directives ...
      #
      # @return [Array]
      def foreground(value = '', &block)
        attributes[:streams] << API::Stream.build({
                                  colour: { foreground: value }
                                }, &block)
      end

      # @param value [String]
      # @param block [Proc]
      #
      # @example
      #   ...
      #     line do
      #       background '#0022ff' do
      #         ... other stream directives ...
      #
      # @return [Array]
      def background(value = '', &block)
        attributes[:streams] << API::Stream.build({
                                  colour: { background: value }
                                }, &block)
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vedeu-0.1.17 lib/vedeu/api/line.rb
vedeu-0.1.16 lib/vedeu/api/line.rb