Class: Kernel::PoorsManStringBuilder
- Defined in:
- lib/guerrilla_patch/kernel.rb
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
- #add(item) ⇒ Object (also: #always)
-
#initialize ⇒ PoorsManStringBuilder
constructor
A new instance of PoorsManStringBuilder.
- #when(item, &block) ⇒ Object
- #when_present(item, &block) ⇒ Object
Constructor Details
#initialize ⇒ PoorsManStringBuilder
Returns a new instance of PoorsManStringBuilder.
32 33 34 |
# File 'lib/guerrilla_patch/kernel.rb', line 32 def initialize @result = '' end |
Instance Attribute Details
#result ⇒ Object (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 |