Sha256: 022ba7f1e6ac866c865b1f3a86c512ad2d42db19bec9a9ad5c0ebcb3e2b33a9b

Contents?: true

Size: 1.65 KB

Versions: 12

Compression:

Stored size: 1.65 KB

Contents

module Vedeu

  module Borders

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

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

      # Returns a new instance of Vedeu::Borders::Null.
      #
      # @param attributes [Hash<Symbol => void>]
      # @option attributes name [String|NilClass]
      # @return [Vedeu::Borders::Null]
      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::Geometry::Repository#by_name)
      def geometry
        @geometry ||= Vedeu.geometries.by_name(name)
      end

    end # Null

  end # Borders

end # Vedeu

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
vedeu-0.6.20 lib/vedeu/borders/null.rb
vedeu-0.6.19 lib/vedeu/borders/null.rb
vedeu-0.6.18 lib/vedeu/borders/null.rb
vedeu-0.6.17 lib/vedeu/borders/null.rb
vedeu-0.6.16 lib/vedeu/borders/null.rb
vedeu-0.6.15 lib/vedeu/borders/null.rb
vedeu-0.6.14 lib/vedeu/borders/null.rb
vedeu-0.6.13 lib/vedeu/borders/null.rb
vedeu-0.6.12 lib/vedeu/borders/null.rb
vedeu-0.6.11 lib/vedeu/borders/null.rb
vedeu-0.6.10 lib/vedeu/borders/null.rb
vedeu-0.6.9 lib/vedeu/borders/null.rb