Class: Yardstick::ReportOutput

Inherits:
Object
  • Object
show all
Defined in:
lib/yardstick/report_output.rb

Overview

Handles writing reports

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target) ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes ReportOutput instance

Parameters:

  • target (Pathname)


25
26
27
# File 'lib/yardstick/report_output.rb', line 25

def initialize(target)
  @target = target
end

Class Method Details

.coerce(target) ⇒ Yardstick::ReportOutput

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Coerces string path into proper output object

Parameters:

  • target (String, Pathname)

    path of the output

Returns:



14
15
16
# File 'lib/yardstick/report_output.rb', line 14

def self.coerce(target)
  new(Pathname(target))
end

Instance Method Details

#to_sString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)

See Also:

  • Yardstick::ReportOutput.[Pathname[Pathname#to_s]


50
51
52
# File 'lib/yardstick/report_output.rb', line 50

def to_s
  @target.to_s
end

#write {|io| ... } ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Open up a report for writing

Yields:

  • (io)

    yield to an object that responds to #puts

Yield Parameters:

  • io (#puts)

    the object that responds to #puts

Returns:

  • (undefined)


40
41
42
43
# File 'lib/yardstick/report_output.rb', line 40

def write(&block)
  @target.dirname.mkpath
  @target.open('w', &block)
end