Complete the code to define a module method that can be used as a class method.
module Greetings def [1](name) "Hello, #{name}!" end end
The method inside the module is defined normally. To use it as a class method, it will be extended later.
Complete the code to extend the module as class methods in the class.
class Person extend [1] end
Using extend Greetings adds the module methods as class methods to Person.
Fix the error in calling the class method from the module.
puts Person.[1]("Alice")
The class method is called directly on the class with the method name defined in the module.
Fill both blanks to define and extend a module with a class method.
module Logger def [1](msg) puts "Log: #{msg}" end end class App [2] Logger end
Define the method 'log' in the module and use 'extend' to add it as a class method to App.
Fill all three blanks to create a module with a class method and call it.
module Utils def [1](value) value * 2 end end class Calculator [2] Utils end result = Calculator.[3](5) puts result
The method 'double' is defined in the module. The class extends the module to get class methods. Then the method is called on the class.