Class: Tables

Inherits:
Object
  • Object
show all
Defined in:
lib/ymldot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table_node, label = nil, category = false) ⇒ Tables

Returns a new instance of Tables.



43
44
45
46
47
48
49
50
# File 'lib/ymldot.rb', line 43

def initialize(table_node, label=nil, category=false)
  @label = label
  @category = category
  @table_node = table_node
  @entity_dict = {}
  @natural_order_entity = []
  table_node.each {|t| eval_entity(t) }
end

Instance Attribute Details

#categoryObject

Returns the value of attribute category.



51
52
53
# File 'lib/ymldot.rb', line 51

def category
  @category
end

#entity_dictObject

Returns the value of attribute entity_dict.



51
52
53
# File 'lib/ymldot.rb', line 51

def entity_dict
  @entity_dict
end

#labelObject

Returns the value of attribute label.



51
52
53
# File 'lib/ymldot.rb', line 51

def label
  @label
end

#table_nodeObject

Returns the value of attribute table_node.



51
52
53
# File 'lib/ymldot.rb', line 51

def table_node
  @table_node
end

Instance Method Details

#add_entity(table) ⇒ Object



70
71
72
# File 'lib/ymldot.rb', line 70

def add_entity(table)
  eval_entity(table)
end

#to_csvObject



64
65
66
67
68
# File 'lib/ymldot.rb', line 64

def to_csv
  res = ""
  @natural_order_entity.each{|e| res << e.to_csv << "\n"}
  res
end

#to_dotObject



53
54
55
56
57
58
59
60
61
62
# File 'lib/ymldot.rb', line 53

def to_dot
  res = ""
  s = @natural_order_entity
  if @category
    res << "label=#{@label}\n" if @label
    res << "style=invis\n" unless @label
  end
  s.each{|e| res << e.to_dot << "\n"}
  res
end