Sha256: 02d1eab518678c83830b4b17d067c7fa1a96af6e9f99482d79c7efe590583f40

Contents?: true

Size: 1.1 KB

Versions: 6

Compression:

Stored size: 1.1 KB

Contents

module Tap
  module Support
    module Lazydoc
      class Definition < Comment
        attr_accessor :subclass
        
        def configurations(fragment_sep=" ", line_sep="\n", strip=true)
          lines = []
          subclass.configurations.each do |receiver, key, config|
            desc = config.desc
            case desc
            when Definition
              lines << "# #{desc.subclass}"
              lines.concat desc.original_to_s(fragment_sep, nil, strip).collect {|line| "# #{line}"}
              lines << "#{key}:"
              lines.concat desc.configurations(fragment_sep).collect {|line| "  #{line}"}
            else 
              lines << "# #{desc}"
              lines << "#{key}: #{config.default}"
              lines << ""
            end
          end
          
          lines
        end
        
        alias original_to_s to_s
        
        def to_s(fragment_sep=" ", line_sep="\n", strip=true)
          lines = [original_to_s(fragment_sep, line_sep, strip)] + configurations(fragment_sep)
          line_sep ? lines.join(line_sep) : lines
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
bahuvrihi-tap-0.10.8 lib/tap/support/lazydoc/definition.rb
bahuvrihi-tap-0.11.0 lib/tap/support/lazydoc/definition.rb
bahuvrihi-tap-0.11.1 lib/tap/support/lazydoc/definition.rb
bahuvrihi-tap-0.11.2 lib/tap/support/lazydoc/definition.rb
tap-0.11.1 lib/tap/support/lazydoc/definition.rb
tap-0.11.0 lib/tap/support/lazydoc/definition.rb