Class: CodeObject::Base

Inherits:
Object
  • Object
show all
Includes:
Dom::Node, Parser::MetaContainer, Token::Container
Defined in:
lib/code_object/base.rb

Constant Summary

Constants included from Dom::Node

Dom::Node::ABSOLUTE, Dom::Node::LEAF, Dom::Node::NODENAME, Dom::Node::NS_SEP, Dom::Node::NS_SEP_STRING, Dom::Node::RELATIVE

Instance Attribute Summary collapse

Attributes included from Parser::MetaContainer

#filepath, #line_start, #source

Instance Method Summary collapse

Methods included from Parser::MetaContainer

#add_meta_data, #clone_meta

Methods included from Dom::Node

#[], #add_node, #children, #each_child, #find, #has_children?, #namespace, #parent, #parents, #print_tree, #qualified_name, #resolve, #siblings

Methods included from Token::Container

#add_token, #process_token, #process_tokens, #token, #tokens

Constructor Details

#initialize(path = "NO_PATH_SPECIFIED") ⇒ Base

The name instance variable is required by Dom::Node



17
18
19
20
21
# File 'lib/code_object/base.rb', line 17

def initialize(path = "NO_PATH_SPECIFIED")      
  path = path.to_s.split(/\s/).first # remove trailing spaces    
  @path, @name = path, extract_name_from(path)
  super()
end

Instance Attribute Details

#docsObject

Returns the value of attribute docs.



14
15
16
# File 'lib/code_object/base.rb', line 14

def docs
  @docs
end

#nameObject (readonly)

Returns the value of attribute name.



14
15
16
# File 'lib/code_object/base.rb', line 14

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



14
15
16
# File 'lib/code_object/base.rb', line 14

def path
  @path
end

Instance Method Details

#display_nameObject

can be overriden by subclasses



34
35
36
# File 'lib/code_object/base.rb', line 34

def display_name
  @name
end

#to_sObject



23
24
25
26
# File 'lib/code_object/base.rb', line 23

def to_s
  token_names = @tokens.keys if @tokens
  "#<#{self.class}:#{self.name} @parent=#{parent.name if parent} @children=#{@children.keys} @tokens=#{token_names}>"
end