Class: Pgerd::Erd::ViewNode
- Inherits:
-
Object
- Object
- Pgerd::Erd::ViewNode
- Defined in:
- lib/pgerd/erd/view_node.rb
Constant Summary collapse
- VIEW_TEMPLATE =
"<table border=\"1\" align=\"center\" cellborder=\"0\" cellpadding=\"2\" cellspacing=\"2\">\n <tr><td bgcolor=\"#fafaf8\" align=\"center\" cellpadding=\"8\"><font point-size=\"11\"><%= name %> *view*</font></td></tr>\n <% grouped_columns.each_with_index do |group, index| %>\n <% if index > 0 %>\n <tr><td height='3'></td></tr>\n <% end %>\n <% group.each do |column| %>\n <tr>\n <td align=\"left\" port=\"<%= column.name %>\"><%= column.name %> <font color=\"grey60\"><%= column.abbreviated_data_type %></font></td>\n </tr>\n <% end %>\n <% end %>\n</table>\n"
Instance Attribute Summary collapse
-
#groups_to_hide ⇒ Object
readonly
Returns the value of attribute groups_to_hide.
-
#view ⇒ Object
readonly
Returns the value of attribute view.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(view, options = {}) ⇒ ViewNode
constructor
A new instance of ViewNode.
- #to_html ⇒ Object
Constructor Details
#initialize(view, options = {}) ⇒ ViewNode
Returns a new instance of ViewNode.
24 25 26 27 28 29 30 |
# File 'lib/pgerd/erd/view_node.rb', line 24 def initialize(view, = {}) @view = view @groups_to_hide = [] @groups_to_hide << :id unless .fetch(:show_id, true) @groups_to_hide << :timestamps unless .fetch(:show_timestamps, true) end |
Instance Attribute Details
#groups_to_hide ⇒ Object (readonly)
Returns the value of attribute groups_to_hide.
22 23 24 |
# File 'lib/pgerd/erd/view_node.rb', line 22 def groups_to_hide @groups_to_hide end |
#view ⇒ Object (readonly)
Returns the value of attribute view.
22 23 24 |
# File 'lib/pgerd/erd/view_node.rb', line 22 def view @view end |
Class Method Details
.render(view, options = {}) ⇒ Object
32 33 34 |
# File 'lib/pgerd/erd/view_node.rb', line 32 def self.render(view, = {}) new(view, ).to_html end |
Instance Method Details
#to_html ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/pgerd/erd/view_node.rb', line 36 def to_html grouped_columns = @view.columns .reject { |column| @groups_to_hide.include? column.group } .group_by(&:group) .values ErbalT.new(name: @view.name, grouped_columns: grouped_columns).render(VIEW_TEMPLATE).strip end |