Class: Kernel::PoorsManStringBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/guerrilla_patch/kernel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePoorsManStringBuilder

Returns a new instance of PoorsManStringBuilder.



32
33
34
# File 'lib/guerrilla_patch/kernel.rb', line 32

def initialize
  @result = ''
end

Instance Attribute Details

#resultObject (readonly)

Returns the value of attribute result.



30
31
32
# File 'lib/guerrilla_patch/kernel.rb', line 30

def result
  @result
end

Instance Method Details

#add(item) ⇒ Object Also known as: always



36
37
38
# File 'lib/guerrilla_patch/kernel.rb', line 36

def add(item)
  @result << item.to_s
end

#when(item, &block) ⇒ Object



45
46
47
48
# File 'lib/guerrilla_patch/kernel.rb', line 45

def when(item, &block)
  return unless item
  @result << Kernel.when_present(item, &block).to_s
end

#when_present(item, &block) ⇒ Object



41
42
43
# File 'lib/guerrilla_patch/kernel.rb', line 41

def when_present(item, &block)
  @result << Kernel.when_present(item, &block).to_s
end