class Prct07::SimpleExpec

Attributes

distractor[RW]
verd[RW]

Public Class Methods

new(args) click to toggle source
Calls superclass method Prct07::Preg::new
# File lib/prct07/simple_expec.rb, line 9
def initialize(args)
       super(args[:text])
       @verd = args[:verd]
       raise ArgumentError, 'Specify :right' unless @verd
       @distractor = args[:distractor]
       raise ArgumentError, 'Specify :distractor' unless @distractor
end

Public Instance Methods

<=(other) click to toggle source
# File lib/prct07/simple_expec.rb, line 32
def <= (other)
      distractor.size <= other.distractor.size
end
>=(other) click to toggle source
# File lib/prct07/simple_expec.rb, line 36
def >= (other)
      distractor.size >= other.distractor.size
end
to_html() click to toggle source
# File lib/prct07/simple_expec.rb, line 16
def to_html
       options = @distractor+[@verd]
       options = options.sample       # Metodo que baraja un array
       options = ''
       options.each do |options|
       options +=  %Q{<input type = "radio" value= "#{options}" name = 0 > #{options}\n}
       html = %Q{
       {#{@text}}<br/>
       {#{options}}
       }
       end
end
to_s() click to toggle source
# File lib/prct07/simple_expec.rb, line 28
def to_s
    "#{@text}#{@verd}#{@distractor}"
end