Class: Rainbow::Wrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/rainbow/wrapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(enabled = true) ⇒ Wrapper

Returns a new instance of Wrapper.



10
11
12
# File 'lib/rainbow/wrapper.rb', line 10

def initialize(enabled = true)
  @enabled = enabled
end

Instance Attribute Details

#enabledObject

Returns the value of attribute enabled.



8
9
10
# File 'lib/rainbow/wrapper.rb', line 8

def enabled
  @enabled
end

Instance Method Details

#wrap(string) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/rainbow/wrapper.rb', line 14

def wrap(string)
  if enabled
    Presenter.new(string.to_s)
  else
    NullPresenter.new(string.to_s)
  end
end