Class: CodeObject
- Inherits:
-
Object
- Object
- CodeObject
- Defined in:
- lib/ruby_diff/structure_processor.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#sexp ⇒ Object
readonly
Returns the value of attribute sexp.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #child_signatures ⇒ Object
-
#initialize(name, parent = nil, sexp = Sexp.new) ⇒ CodeObject
constructor
A new instance of CodeObject.
- #signature ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, parent = nil, sexp = Sexp.new) ⇒ CodeObject
Returns a new instance of CodeObject.
7 8 9 10 11 12 13 14 15 |
# File 'lib/ruby_diff/structure_processor.rb', line 7 def initialize(name, parent=nil, sexp=Sexp.new) @name = name @parent = parent @sexp = sexp.deep_clone @children = [] if parent parent.children << self end end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
4 5 6 |
# File 'lib/ruby_diff/structure_processor.rb', line 4 def children @children end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
2 3 4 |
# File 'lib/ruby_diff/structure_processor.rb', line 2 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
3 4 5 |
# File 'lib/ruby_diff/structure_processor.rb', line 3 def parent @parent end |
#sexp ⇒ Object (readonly)
Returns the value of attribute sexp.
5 6 7 |
# File 'lib/ruby_diff/structure_processor.rb', line 5 def sexp @sexp end |
Instance Method Details
#==(other) ⇒ Object
31 32 33 34 |
# File 'lib/ruby_diff/structure_processor.rb', line 31 def ==(other) return false unless other.class == self.class (other.signature == self.signature) and (other.sexp == self.sexp) end |
#child_signatures ⇒ Object
21 22 23 24 25 |
# File 'lib/ruby_diff/structure_processor.rb', line 21 def child_signatures h = {} self.children.each{|c| h[c.signature] = c} h end |
#signature ⇒ Object
17 18 19 |
# File 'lib/ruby_diff/structure_processor.rb', line 17 def signature self.name end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/ruby_diff/structure_processor.rb', line 27 def to_s signature end |