Sha256: 771543d601c801ee961f86c0d63b44eef72fa678052490fdeb05b83dfca0642b

Contents?: true

Size: 729 Bytes

Versions: 3

Compression:

Stored size: 729 Bytes

Contents

module RTFM
  class GroffString
    
    attr_reader :source
    
    def self.groffify(str = "")
      out = self.new(str)
      yield out
      out.to_s
    end
    
    def initialize(str = "")
      @source = str.dup
    end
    
    def to_s
      source
    end
    
    def rstrip
      source.rstrip
    end
    
    def add_line(line)
      source << line.rstrip << "\n"
    end
    alias_method :<<, :add_line
    
    def section(section)
      self.Sh section.upcase
    end
    
    def put_name
      self.Nm
    end
    
    def reference(page, section = nil)
      self.Xr page, (section || "")
    end
    
    def method_missing(meth, *args, &block)
      add_line ".#{meth} #{args.join(" ")}"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rtfm-0.5.2 lib/rtfm/groffstring.rb
rtfm-0.5.1 lib/rtfm/groffstring.rb
rtfm-0.5.0 lib/rtfm/groffstring.rb