Class: LetterPress::Ghost
- Inherits:
-
Object
- Object
- LetterPress::Ghost
show all
- Defined in:
- lib/letter_press/ghost.rb
Instance Method Summary
collapse
Constructor Details
#initialize(serial_number) ⇒ Ghost
Returns a new instance of Ghost.
3
4
5
|
# File 'lib/letter_press/ghost.rb', line 3
def initialize(serial_number)
@serial_number = serial_number
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/letter_press/ghost.rb', line 15
def method_missing(method, *args, &block)
if block_given?
keys << method
m = Module.new do
define_method(method, &block)
end
extend m
else
super
end
end
|
Instance Method Details
#keys ⇒ Object
11
12
13
|
# File 'lib/letter_press/ghost.rb', line 11
def keys
@keys ||= []
end
|
#sn ⇒ Object
7
8
9
|
# File 'lib/letter_press/ghost.rb', line 7
def sn
@serial_number.next
end
|