Class: Codetree::Operator
- Inherits:
-
Object
- Object
- Codetree::Operator
- Defined in:
- lib/codetree.rb
Instance Attribute Summary collapse
-
#ancestors ⇒ Object
readonly
Returns the value of attribute ancestors.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#scope ⇒ Object
Returns the value of attribute scope.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Virtual Scopeors collapse
Instance Method Summary collapse
-
#initialize(_options = { :type => :defn, :ancestors => [], :scope => :none, :name => "", :line => 0 }) ⇒ Operator
constructor
A new instance of Operator.
- #render ⇒ Object
Constructor Details
#initialize(_options = { :type => :defn, :ancestors => [], :scope => :none, :name => "", :line => 0 }) ⇒ Operator
Returns a new instance of Operator.
17 18 19 20 21 22 23 |
# File 'lib/codetree.rb', line 17 def initialize( = { :type => :defn, :ancestors => [], :scope => :none, :name => "", :line => 0 }) @type = [:type] || :defn @ancestors = [:ancestors] || [] @scope = [:scope] || :none @name = [:name] || "" @line = [:line] || 0 end |
Instance Attribute Details
#ancestors ⇒ Object (readonly)
Returns the value of attribute ancestors.
12 13 14 |
# File 'lib/codetree.rb', line 12 def ancestors @ancestors end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
14 15 16 |
# File 'lib/codetree.rb', line 14 def line @line end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
15 16 17 |
# File 'lib/codetree.rb', line 15 def name @name end |
#scope ⇒ Object
Returns the value of attribute scope.
13 14 15 |
# File 'lib/codetree.rb', line 13 def scope @scope end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
11 12 13 |
# File 'lib/codetree.rb', line 11 def type @type end |
Instance Method Details
#ancestor ⇒ Object
27 28 29 |
# File 'lib/codetree.rb', line 27 def ancestor return @ancestors.last end |
#render ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/codetree.rb', line 35 def render return name.to_s if self.ancestors == [] case type when :defn then return "##{name.to_s}" when :defs then return ".#{name.to_s}" when :class then return "::#{name.to_s}" when :module then return "::#{name.to_s}" end end |