Class: SeleccionSimple
- Inherits:
-
Object
- Object
- SeleccionSimple
- Includes:
- Comparable
- Defined in:
- lib/exam1/SeleccionSimple.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#nivel ⇒ Object
readonly
Returns the value of attribute nivel.
-
#pregunta ⇒ Object
readonly
Returns the value of attribute pregunta.
-
#rescorr ⇒ Object
readonly
Returns the value of attribute rescorr.
-
#respuesta ⇒ Object
readonly
Returns the value of attribute respuesta.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
-
#initialize(pregunta, respuesta, nivel, rescorr) ⇒ SeleccionSimple
constructor
A new instance of SeleccionSimple.
-
#to_s ⇒ Object
para respuestas de 4 opciones.
Constructor Details
#initialize(pregunta, respuesta, nivel, rescorr) ⇒ SeleccionSimple
Returns a new instance of SeleccionSimple.
8 9 10 11 12 13 |
# File 'lib/exam1/SeleccionSimple.rb', line 8 def initialize(pregunta,respuesta,nivel,rescorr) @pregunta=pregunta @respuesta=respuesta @nivel=nivel @rescorr=rescorr end |
Instance Attribute Details
#nivel ⇒ Object (readonly)
Returns the value of attribute nivel.
2 3 4 |
# File 'lib/exam1/SeleccionSimple.rb', line 2 def nivel @nivel end |
#pregunta ⇒ Object (readonly)
Returns the value of attribute pregunta.
2 3 4 |
# File 'lib/exam1/SeleccionSimple.rb', line 2 def pregunta @pregunta end |
#rescorr ⇒ Object (readonly)
Returns the value of attribute rescorr.
2 3 4 |
# File 'lib/exam1/SeleccionSimple.rb', line 2 def rescorr @rescorr end |
#respuesta ⇒ Object (readonly)
Returns the value of attribute respuesta.
2 3 4 |
# File 'lib/exam1/SeleccionSimple.rb', line 2 def respuesta @respuesta end |
Instance Method Details
#<=>(other) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/exam1/SeleccionSimple.rb', line 21 def <=>(other) =begin for i in (0..3) respuesta_size += @respuesta[i].size respuesta_other_size += other.respuesta[i].size end =end return nil unless other.is_a?SeleccionSimple @nivel <=> other.nivel #@pregunta.size + respuesta_size <=> other.pregunta.size + respuesta_other_size end |
#==(other) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/exam1/SeleccionSimple.rb', line 36 def ==(other) return nil unless other.is_a?SeleccionSimple if @nivel == other.nivel @respuesta == other.respuesta end #return nil unless other.is_a?SeleccionSimple @pregunta == other.pregunta end |
#to_s ⇒ Object
para respuestas de 4 opciones
16 17 18 19 |
# File 'lib/exam1/SeleccionSimple.rb', line 16 def to_s #para respuestas de 4 opciones "#{@pregunta}\n a) #{@respuesta[0]}\n b) #{@respuesta[1]}\n c) #{@respuesta[2]}\n d) #{@respuesta[3]}\n" end |