Class: SeleccionSimple

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/exam1/SeleccionSimple.rb

Direct Known Subclasses

Verdadero_Falso

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nivelObject (readonly)

Returns the value of attribute nivel.



2
3
4
# File 'lib/exam1/SeleccionSimple.rb', line 2

def nivel
  @nivel
end

#preguntaObject (readonly)

Returns the value of attribute pregunta.



2
3
4
# File 'lib/exam1/SeleccionSimple.rb', line 2

def pregunta
  @pregunta
end

#rescorrObject (readonly)

Returns the value of attribute rescorr.



2
3
4
# File 'lib/exam1/SeleccionSimple.rb', line 2

def rescorr
  @rescorr
end

#respuestaObject (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_sObject

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