Class: Difficult

Inherits:
Object
  • Object
show all
Defined in:
lib/console_app/difficult.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(level) ⇒ Difficult

Returns a new instance of Difficult.



4
5
6
# File 'lib/console_app/difficult.rb', line 4

def initialize(level)
  @level = level.downcase
end

Instance Attribute Details

#levelObject (readonly)

Returns the value of attribute level.



2
3
4
# File 'lib/console_app/difficult.rb', line 2

def level
  @level
end

Instance Method Details

#to_iObject



8
9
10
11
12
13
14
# File 'lib/console_app/difficult.rb', line 8

def to_i
  case @level
  when name('hell') then 1
  when name('medium') then 2
  when name('easy') then 3
  end
end