Sha256: b8b7366ecd7dac8d7403c138580ae0296c706c2ed382b0c5083a9f8a07309499

Contents?: true

Size: 1.62 KB

Versions: 28

Compression:

Stored size: 1.62 KB

Contents

module Vedeu

  module Null

    # Provides a non-existent Vedeu::Border that acts like the real thing, but
    # does nothing.
    #
    class Border

      # @!attribute [r] name
      # @return [String|NilClass]
      attr_reader :name

      # Returns a new instance of Vedeu::Null::Border.
      #
      # @param attributes [Hash<Symbol => void>]
      # @option attributes name [String|NilClass]
      # @return [Vedeu::Null::Border]
      def initialize(attributes = {})
        @attributes = attributes
        @name       = @attributes[:name]
      end

      # @return [Fixnum]
      def bx
        geometry.x
      end
      alias_method :x, :bx

      # @return [Fixnum]
      def bxn
        geometry.xn
      end
      alias_method :xn, :bxn

      # @return [Fixnum]
      def by
        geometry.y
      end
      alias_method :y, :by

      # @return [Fixnum]
      def byn
        geometry.yn
      end
      alias_method :yn, :byn

      # The null border should not be enabled, so that named geometry
      # or null geometry is used.
      #
      # @return [FalseClass]
      def enabled?
        false
      end

      # @return [Fixnum]
      def height
        (by..byn).size
      end

      # @return [Boolean]
      def null?
        true
      end

      # @return [Array]
      def render
        []
      end

      # @return [Fixnum]
      def width
        (bx..bxn).size
      end

      private

      # Returns the geometry for the interface.
      #
      # @return (see Vedeu::Geometries#by_name)
      def geometry
        @geometry ||= Vedeu.geometries.by_name(name)
      end

    end # Border

  end # Null

end # Vedeu

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
vedeu-0.4.64 lib/vedeu/null/border.rb
vedeu-0.4.63 lib/vedeu/null/border.rb
vedeu-0.4.62 lib/vedeu/null/border.rb
vedeu-0.4.61 lib/vedeu/null/border.rb
vedeu-0.4.60 lib/vedeu/null/border.rb
vedeu-0.4.59 lib/vedeu/null/border.rb
vedeu-0.4.58 lib/vedeu/null/border.rb
vedeu-0.4.57 lib/vedeu/null/border.rb