File: interaction_presenter.rb

package info (click to toggle)
ruby-bogus 0.1.6-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 860 kB
  • sloc: ruby: 4,219; makefile: 8; sh: 2
file content (29 lines) | stat: -rw-r--r-- 481 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
module Bogus
  class InteractionPresenter
    extend Takes

    takes :interaction

    def to_s
      "##{interaction.method}(#{args})#{result}"
    end

    private

    def args
      interaction.args.map(&:inspect).join(', ')
    end

    def result
      error || return_value
    end

    def return_value
      " => #{interaction.return_value.inspect}" if interaction.has_result
    end

    def error
      " !! #{interaction.error}" if interaction.error
    end
  end
end