Sha256: f4024c02ffd1c4d663aea7d3200f64caeb7e410aead9b5293f45f4bd2ba39ec2

Contents?: true

Size: 559 Bytes

Versions: 7

Compression:

Stored size: 559 Bytes

Contents

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

    def initialize(answer, options, num, &block)
      @answer  = answer
      @options = options
      @num     = num
      @action  = 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

7 entries across 7 versions & 1 rubygems

Version Path
playmo-0.1.6 lib/playmo/answer.rb
playmo-0.1.5 lib/playmo/answer.rb
playmo-0.1.4 lib/playmo/answer.rb
playmo-0.1.3 lib/playmo/answer.rb
playmo-0.1.2 lib/playmo/answer.rb
playmo-0.1.1 lib/playmo/answer.rb
playmo-0.1.0 lib/playmo/answer.rb