Sha256: e62ba71c65cb83072f1bdf48039b22c29e191e1cd384a08762e1fe7e7ddc8260

Contents?: true

Size: 558 Bytes

Versions: 4

Compression:

Stored size: 558 Bytes

Contents

module Playmo
  class Answer
    attr_accessor :answer, :options, :num, :block, :color

    def initialize(answer, options, num, &block)
      @answer  = answer
      @options = options
      @num     = num
      @block   = block
      @color   = Thor::Shell::Color.new
    end

    def default?
      options.try(:[], :default) == true
    end

    def render
      if @answer
        result = color.set_color("#{@num}. #{@answer}", :white, true)
        result << " (default)" if default?
        result
      end
    end

    alias :to_s :render
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
playmo-0.1.10 lib/playmo/answer.rb
playmo-0.1.9 lib/playmo/answer.rb
playmo-0.1.8 lib/playmo/answer.rb
playmo-0.1.7 lib/playmo/answer.rb