Class: Snuffle::Node
- Inherits:
-
Object
- Object
- Snuffle::Node
- Includes:
- Ephemeral::Base, PoroPlus
- Defined in:
- lib/snuffle/node.rb
Instance Attribute Summary collapse
-
#child_ids ⇒ Object
Returns the value of attribute child_ids.
-
#id ⇒ Object
Returns the value of attribute id.
-
#line_numbers ⇒ Object
Returns the value of attribute line_numbers.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent_id ⇒ Object
Returns the value of attribute parent_id.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #children ⇒ Object
-
#initialize(*args, &block) ⇒ Node
constructor
A new instance of Node.
- #inspect ⇒ Object
- #is_method ⇒ Object
- #is_send ⇒ Object
- #parent ⇒ Object
- #siblings ⇒ Object
Constructor Details
#initialize(*args, &block) ⇒ Node
Returns a new instance of Node.
25 26 27 28 |
# File 'lib/snuffle/node.rb', line 25 def initialize(*args, &block) @id = SecureRandom.uuid super end |
Instance Attribute Details
#child_ids ⇒ Object
Returns the value of attribute child_ids.
8 9 10 |
# File 'lib/snuffle/node.rb', line 8 def child_ids @child_ids end |
#id ⇒ Object
Returns the value of attribute id.
8 9 10 |
# File 'lib/snuffle/node.rb', line 8 def id @id end |
#line_numbers ⇒ Object
Returns the value of attribute line_numbers.
8 9 10 |
# File 'lib/snuffle/node.rb', line 8 def line_numbers @line_numbers end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/snuffle/node.rb', line 8 def name @name end |
#parent_id ⇒ Object
Returns the value of attribute parent_id.
8 9 10 |
# File 'lib/snuffle/node.rb', line 8 def parent_id @parent_id end |
#type ⇒ Object
Returns the value of attribute type.
8 9 10 |
# File 'lib/snuffle/node.rb', line 8 def type @type end |
Class Method Details
.nil ⇒ Object
17 18 19 |
# File 'lib/snuffle/node.rb', line 17 def self.nil new(type: :nil) end |
.not_a(type) ⇒ Object
21 22 23 |
# File 'lib/snuffle/node.rb', line 21 def self.not_a(type) select{|node| node.type != type} end |
Instance Method Details
#children ⇒ Object
38 39 40 |
# File 'lib/snuffle/node.rb', line 38 def children Snuffle::Node.where(parent_id: self.id) end |
#inspect ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/snuffle/node.rb', line 50 def inspect { id: self.id, type: self.type, parent_id: self.parent_id, child_ids: self.child_ids }.to_s end |
#is_method ⇒ Object
42 43 44 |
# File 'lib/snuffle/node.rb', line 42 def is_method self.type == :def || self.type == :defs end |
#is_send ⇒ Object
46 47 48 |
# File 'lib/snuffle/node.rb', line 46 def is_send self.type == :send end |