Module: RVC::InventoryObject

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#rvc_arcObject (readonly)

Returns the value of attribute rvc_arc.



38
39
40
# File 'lib/rvc/inventory.rb', line 38

def rvc_arc
  @rvc_arc
end

#rvc_parentObject (readonly)

Returns the value of attribute rvc_parent.



38
39
40
# File 'lib/rvc/inventory.rb', line 38

def rvc_parent
  @rvc_parent
end

Class Method Details

.included(m) ⇒ Object



34
35
36
# File 'lib/rvc/inventory.rb', line 34

def self.included m
  m.extend ClassMethods
end

Instance Method Details

#childrenObject



52
53
54
# File 'lib/rvc/inventory.rb', line 52

def children
  {}
end

#display_infoObject



40
41
42
# File 'lib/rvc/inventory.rb', line 40

def display_info
  puts "class: #{self.class.name}"
end

#ls_text(r) ⇒ Object



44
45
46
# File 'lib/rvc/inventory.rb', line 44

def ls_text r
  self.class.folder? ? '/' : ''
end


71
72
73
74
75
# File 'lib/rvc/inventory.rb', line 71

def rvc_link parent, arc
  return if @rvc_parent
  @rvc_parent = parent
  @rvc_arc = arc
end

#rvc_pathObject



56
57
58
59
60
61
62
63
64
65
# File 'lib/rvc/inventory.rb', line 56

def rvc_path
  [].tap do |a|
    cur = self
    while cur != nil
      a << [cur.rvc_arc, cur]
      cur = cur.rvc_parent
    end
    a.reverse!
  end
end

#rvc_path_strObject



67
68
69
# File 'lib/rvc/inventory.rb', line 67

def rvc_path_str
  rvc_path.map { |k,v| k } * '/'
end

#traverse_one(arc) ⇒ Object



48
49
50
# File 'lib/rvc/inventory.rb', line 48

def traverse_one arc
  children[arc]
end