Module: StringMasterProxy

Included in:
String
Defined in:
lib/string_master/string_master_proxy.rb

Instance Method Summary collapse

Instance Method Details

#prepObject

This should be used on a String to get access to StringMaster’s methods. Two notations are available:

  • Block notation:

    String#prep { |s| s.cut(...); s.break_long_words }
    
  • Chained methods notation

    String#prep.cut(...).break_long_words(...)
    

Beware that in (1) a String object is returned, while in (2) a StringMaster object is returned (although StringMaster has a #to_s method).



12
13
14
15
16
17
18
19
20
# File 'lib/string_master/string_master_proxy.rb', line 12

def prep
  if block_given?
    @string_master ||= StringMaster.new(self)
    self.replace yield(@string_master).to_s
    self
  else
    StringMaster.new(self)
  end
end