From 07a9de4f2dd33e76a4e5a62c37de5a912bb618dc Mon Sep 17 00:00:00 2001 From: "Abinoam P. Marques Jr" Date: Thu, 29 Jun 2017 03:45:02 -0300 Subject: Create a default instance and forward class methods to it --- lib/highline.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/highline.rb b/lib/highline.rb index a8b72d4..ea4a47e 100755 --- a/lib/highline.rb +++ b/lib/highline.rb @@ -44,8 +44,14 @@ class HighLine include BuiltinStyles include CustomErrors + @default_instance = new + + extend SingleForwardable + def_single_delegators :@default_instance, :agree, :ask, :choose, :say, + :use_color=, :use_color?, :reset_use_color + def self.default_instance - @default_instance ||= new + @default_instance end def self.default_instance=(highline_instance) -- cgit v1.2.1