-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctional_strategy_pattern.rb
More file actions
50 lines (43 loc) · 1.04 KB
/
Copy pathfunctional_strategy_pattern.rb
File metadata and controls
50 lines (43 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
module Printer
def self.print_preview(print_preview_message)
puts '-> starting the printing preview...'
puts print_preview_message
puts '-> happy with the preview? shall I print now?'
end
def self.print(print_message)
puts '-> initializing...'
puts '-> ...printing'
puts print_message
puts '-> print successful'
end
end
module Pdf
def self.printer_config
{ print_preview: 'pdf preview', print: Printable.message('Pdf') }
end
end
module Html
def self.printer_config
{ print_preview: PreviewLess.message, print: Printable.message('Html') }
end
end
module Photocopy
def self.printer_config
{ print_preview: PreviewLess.message, print: 'photocopy generated' }
end
end
module PreviewLess
def self.message
'no preview available'
end
end
module Printable
def self.message(doc_type)
"#{doc_type} print"
end
end
[Pdf.printer_config, Html.printer_config, Photocopy.printer_config].each do |h|
Printer.print_preview(h[:print_preview])
Printer.print(h[:print])
puts '-------------'
end