class Ytrbium::String

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/ytrbium/string.rb, line 2
def initialize
  super
  @indent = 0
  @last_newline = 0
end

Public Instance Methods

<<(str) click to toggle source
Calls superclass method
# File lib/ytrbium/string.rb, line 8
def <<(str)
  @indent = -1 if str.include?("\n")
  super.tap do
    if @indent == -1
      @last_newline = str.rindex("\n")
      @indent = 0
    end
    if @indent == 0 && self[@last_newline..-1] =~ /\n([- ]+)\Z/m
      @indent = $1.length
    end
  end
end
indent_expr(obj) click to toggle source
# File lib/ytrbium/string.rb, line 21
def indent_expr(obj)
  obj.bare_yaml.indent_by(@indent)
end
to_s() click to toggle source
# File lib/ytrbium/string.rb, line 25
def to_s
  if start_with?("---")
    self
  else
    "---\n#{self}"
  end
end