Sha256: 64ab6abac166b2a1069c5a12d319cb8a60fda6bf2841f03206c2876cc44c34e9

Contents?: true

Size: 475 Bytes

Versions: 7

Compression:

Stored size: 475 Bytes

Contents

module HaveAPI::Fs::Components
  class ComponentList < File
    def read
      str = component_list.map do |c|
        sprintf('%-50s %s', c.class.name, c.path)
      end.join("\n")
      str += "\n" unless str.empty?
      str
    end

    protected
    def component_list(component = nil)
      component ||= parent
      ret = []

      component.send(:children).each do |_, c|
        ret << c
        ret.concat(component_list(c))
      end

      ret
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
haveapi-fs-0.11.0 lib/haveapi/fs/components/component_list.rb
haveapi-fs-0.10.0 lib/haveapi/fs/components/component_list.rb
haveapi-fs-0.9.0 lib/haveapi/fs/components/component_list.rb
haveapi-fs-0.8.0 lib/haveapi/fs/components/component_list.rb
haveapi-fs-0.7.1 lib/haveapi/fs/components/component_list.rb
haveapi-fs-0.7.0 lib/haveapi/fs/components/component_list.rb
haveapi-fs-0.1.0 lib/haveapi/fs/components/component_list.rb