class CLIntegracon::LazyString
A LazyString
is constructed by a block, but only evaluated when needed
Attributes
proc[R]
@return [Proc]
the closure which will be used to build the string
Public Class Methods
new(&block)
click to toggle source
Initialize a LazyString
@param [Block () -> (String)] block
the block which returns a string, called by #to_s
# File lib/CLIntegracon/formatter.rb, line 17 def initialize(&block) @proc = block end
Public Instance Methods
to_str()
click to toggle source
Calls the underlying proc to build the string. The result will be memorized, so subsequent calls of this method will not cause that the proc will be called again.
@return [String]
# File lib/CLIntegracon/formatter.rb, line 27 def to_str @string ||= proc.call().to_s end
Also aliased as: to_s