Class: Radio

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

Constant Summary collapse

MAX_VOLUME =
100
MIN_VOLUME =
0
@@brand =
'SONY_DALIAN'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(volume = 3) ⇒ Radio

attr_writer :volume attr_accessor :volume



12
13
14
# File 'lib/radio.rb', line 12

def initialize(volume = 3)
  @volume = volume
end

Instance Attribute Details

#volumeObject

Returns the value of attribute volume.



8
9
10
# File 'lib/radio.rb', line 8

def volume
  @volume
end

Class Method Details

.brandObject



28
29
30
# File 'lib/radio.rb', line 28

def self.brand
    @@brand
end

.hackObject



49
50
51
# File 'lib/radio.rb', line 49

def hack
    puts 'I hacked in the radio'
end

.wave_bandObject



34
35
36
# File 'lib/radio.rb', line 34

def wave_band
    '100.8'
end

Instance Method Details

#volume_to_1000Object



24
25
26
# File 'lib/radio.rb', line 24

def volume_to_1000
    self.volume = 1000       #调用的是volumn= 方法, 不是直接给@volume赋值
end