class Snuffle::Node

Attributes

args[RW]
child_ids[RW]
id[RW]
line_numbers[RW]
name[RW]
parent_id[RW]
type[RW]

Public Class Methods

new(*args, &block) click to toggle source
Calls superclass method
# File lib/snuffle/node.rb, line 24
def initialize(*args, &block)
  @id = SecureRandom.uuid
  super
end
nil() click to toggle source
# File lib/snuffle/node.rb, line 16
def self.nil
  new(type: :nil)
end
not_a(type) click to toggle source
# File lib/snuffle/node.rb, line 20
def self.not_a(type)
  select{|node| node.type != type}
end

Public Instance Methods

children() click to toggle source
# File lib/snuffle/node.rb, line 37
def children
  Snuffle::Node.where(parent_id: self.id)
end
inspect() click to toggle source
# File lib/snuffle/node.rb, line 49
def inspect
  {
    id: self.id,
    type: self.type,
    parent_id: self.parent_id,
    child_ids: self.child_ids
  }.to_s
end
is_method() click to toggle source
# File lib/snuffle/node.rb, line 41
def is_method
  self.type == :def || self.type == :defs
end
is_send() click to toggle source
# File lib/snuffle/node.rb, line 45
def is_send
  self.type == :send
end
parent() click to toggle source
# File lib/snuffle/node.rb, line 29
def parent
  Snuffle::Node.where(id: self.parent_id).first
end
siblings() click to toggle source
# File lib/snuffle/node.rb, line 33
def siblings
  @siblings ||= Snuffle::Node.by_type(self.type).to_a - [self]
end