Sha256: e98951cd50a8870c09a343c0c76bcc3c4e47ec3c0b87c19b833c45e64ec8a2e5

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 KB

Contents

module Prickle
  module Exceptions
    module Message

      private
      def highlight text
        "\e[1m#{text}\e[0m\e[31m"
      end

      class ElementNotFound
        include Message

        def initialize type=nil, identifier=nil, text=nil, caught_exception=nil
          @element_type = type
          @element_identifier = identifier
          @element_text = text
          @caught_exception = caught_exception
        end

        def to_s
          "#{element_text} with identifier #{identifier}#{text_string} was not found.\n\tError: #{@caught_exception.message}"
        end

        private

        def element_text
          return highlight(@element_type) unless @element_type == "*"
          "Element"
        end

        def text_string
          " and text #{highlight(@element_text)}" unless @element_text.nil?
        end

        def identifier
          highlight(@element_identifier.to_s)
        end
      end

      class TextNotContainedInPopup
        include Message

        def initialize message
          @message = message
        end

        def to_s
          "Text #{highlight(@message)} is not contained in the popup."
        end
      end

    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
prickle-0.1.0 lib/prickle/exceptions/messages.rb
prickle-0.0.6 lib/prickle/exceptions/messages.rb
prickle-0.0.5 lib/prickle/exceptions/messages.rb
prickle-0.0.4 lib/prickle/exceptions/messages.rb