Sha256: 7097b18d0072d66beaacab668ed66e023b88a1b6581c09c0098a9b0568f9fdd2

Contents?: true

Size: 722 Bytes

Versions: 3

Compression:

Stored size: 722 Bytes

Contents

module HackTree
  module Node
    class Base
      # Brief 1-line description, if present.
      attr_accessor :brief_desc

      # Multi-line description, if present.
      attr_accessor :full_desc

      # Node name, Symbol.
      attr_accessor :name

      # Parent group or <tt>nil</tt>.
      attr_accessor :parent

      def initialize(attrs = {})
        attrs.each {|k, v| send("#{k}=", v)}
      end

      #   global_name   # => "hello"
      #   global_name   # => "rails.db.tables"
      def global_name
        pcs = []
        cursor = self
        begin
          pcs << cursor.name
          cursor = cursor.parent
        end while cursor

        pcs.reverse.join(".")
      end
    end # Base
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hack_tree-0.1.2 lib/hack_tree/node/base.rb
hack_tree-0.1.1 lib/hack_tree/node/base.rb
hack_tree-0.1.0 lib/hack_tree/node/base.rb