Class: Radio
- Inherits:
-
Object
- Object
- Radio
- Defined in:
- lib/radio.rb
Constant Summary collapse
- MAX_VOLUME =
100- MIN_VOLUME =
0- @@brand =
'SONY_DALIAN'
Instance Attribute Summary collapse
-
#volume ⇒ Object
Returns the value of attribute volume.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(volume = 3) ⇒ Radio
constructor
attr_writer :volume attr_accessor :volume.
- #volume_to_1000 ⇒ Object
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
#volume ⇒ Object
Returns the value of attribute volume.
8 9 10 |
# File 'lib/radio.rb', line 8 def volume @volume end |
Class Method Details
.brand ⇒ Object
28 29 30 |
# File 'lib/radio.rb', line 28 def self.brand @@brand end |
.hack ⇒ Object
49 50 51 |
# File 'lib/radio.rb', line 49 def hack puts 'I hacked in the radio' end |
.wave_band ⇒ Object
34 35 36 |
# File 'lib/radio.rb', line 34 def wave_band '100.8' end |
Instance Method Details
#volume_to_1000 ⇒ Object
24 25 26 |
# File 'lib/radio.rb', line 24 def volume_to_1000 self.volume = 1000 #调用的是volumn= 方法, 不是直接给@volume赋值 end |