Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/openstudio-standards/btap/btap.rb,
lib/openstudio-standards/utilities/template_measure/resources/BTAPMeasureHelper.rb

Overview

Add colourisation functionality to strings. Makes following test output easier.

Instance Method Summary collapse

Instance Method Details

#blueObject

Use for start of tests/sections



435
436
437
# File 'lib/openstudio-standards/utilities/template_measure/resources/BTAPMeasureHelper.rb', line 435

def blue
  colorize(34)
end

#colorize(color_code) ⇒ Object

colorization



415
416
417
# File 'lib/openstudio-standards/utilities/template_measure/resources/BTAPMeasureHelper.rb', line 415

def colorize(color_code)
  "\e[#{color_code}m#{self}\e[0m"
end

#greenObject

Use for success messages



425
426
427
# File 'lib/openstudio-standards/utilities/template_measure/resources/BTAPMeasureHelper.rb', line 425

def green
  colorize(32)
end

#light_blueObject

Use for argument value reporting



440
441
442
# File 'lib/openstudio-standards/utilities/template_measure/resources/BTAPMeasureHelper.rb', line 440

def light_blue
  colorize(36)
end

#pinkObject

Use for larger text dumps (e.g. whole files)



445
446
447
# File 'lib/openstudio-standards/utilities/template_measure/resources/BTAPMeasureHelper.rb', line 445

def pink
  colorize(35)
end

#redObject

Use for error messages



420
421
422
# File 'lib/openstudio-standards/utilities/template_measure/resources/BTAPMeasureHelper.rb', line 420

def red
  colorize(31)
end

#to_boolObject

This method converts to Boolean.

Raises:

  • (ArgumentError)

Author:



50
51
52
53
54
# File 'lib/openstudio-standards/btap/btap.rb', line 50

def to_bool
  return true if self == true || self =~ (/^(true|t|yes|y|1)$/i)
  return false if self == false  || self =~ (/^(false|f|no|n|0)$/i)
  raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
end

#yellowObject

Use for warning messages



430
431
432
# File 'lib/openstudio-standards/utilities/template_measure/resources/BTAPMeasureHelper.rb', line 430

def yellow
  colorize(33)
end