Class: Examen::Pregunta

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/examen/pregunta.rb

Overview

< Struct.new(“Pregunta”, :enunciado , :respuesta, :falsas)

Direct Known Subclasses

EleccionSimple, Verdaderofalso

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arg) ⇒ Pregunta

Returns a new instance of Pregunta.



21
22
23
24
25
26
# File 'lib/examen/pregunta.rb', line 21

def initialize(arg)
    @valor=arg[:valor]
    @enunciado=arg[:enunciado]
    @respuesta=arg[:respuesta]
    @falsas=arg[:falsas]
end

Instance Attribute Details

#enunciadoObject (readonly)

use a class to define behavior, together with a Struct that defines the data to which the class should be initialized.



Mas general una clase pregunta y que eleccion simple y verdader falso hereden de ella, en pregunta instancear variable ‘ponderacion’ que permita comprar el nivel de dificultad entre dos preguntas distintas





19
20
21
# File 'lib/examen/pregunta.rb', line 19

def enunciado
  @enunciado
end

#falsasObject (readonly)

use a class to define behavior, together with a Struct that defines the data to which the class should be initialized.



Mas general una clase pregunta y que eleccion simple y verdader falso hereden de ella, en pregunta instancear variable ‘ponderacion’ que permita comprar el nivel de dificultad entre dos preguntas distintas





19
20
21
# File 'lib/examen/pregunta.rb', line 19

def falsas
  @falsas
end

#respuestaObject (readonly)

use a class to define behavior, together with a Struct that defines the data to which the class should be initialized.



Mas general una clase pregunta y que eleccion simple y verdader falso hereden de ella, en pregunta instancear variable ‘ponderacion’ que permita comprar el nivel de dificultad entre dos preguntas distintas





19
20
21
# File 'lib/examen/pregunta.rb', line 19

def respuesta
  @respuesta
end

#valorObject (readonly)

use a class to define behavior, together with a Struct that defines the data to which the class should be initialized.



Mas general una clase pregunta y que eleccion simple y verdader falso hereden de ella, en pregunta instancear variable ‘ponderacion’ que permita comprar el nivel de dificultad entre dos preguntas distintas





19
20
21
# File 'lib/examen/pregunta.rb', line 19

def valor
  @valor
end

Instance Method Details

#<=>(other) ⇒ Object



44
45
46
47
# File 'lib/examen/pregunta.rb', line 44

def <=> other
    #return nil unless other.is_a? Examen
     self.valor <=> other.valor
end

#extrespObject



29
30
31
32
33
# File 'lib/examen/pregunta.rb', line 29

def extresp 
     
     "RESPUESTAS : #{@respuesta}, #{@falsas}"
     
end

#pregObject



40
41
42
# File 'lib/examen/pregunta.rb', line 40

def preg 
      "PREGUNTA : #{@enunciado}"
end

#to_sObject



35
36
37
# File 'lib/examen/pregunta.rb', line 35

def to_s
    preg +  extresp
end