Module: RailroadDiagrams::ExpandedNode
- Included in:
- Except, Repeat, SeparatedList
- Defined in:
- lib/railroad_diagrams/expanded_node.rb,
sig/generated/railroad_diagrams/expanded_node.rbs
Overview
Nodes with their own meaning but the geometry of existing nodes.
Instance Method Summary collapse
- #adopt_expansion(node) ⇒ Object
- #expanded(_context = nil) ⇒ Object
- #format(x, y, width) ⇒ Object
- #measure(context) ⇒ Object
- #render_svg(context, x, y, width) ⇒ Object
- #render_text(context) ⇒ Object
- #text_diagram ⇒ Object
- #walk(callback) ⇒ Object
Instance Method Details
#adopt_expansion(node) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/railroad_diagrams/expanded_node.rb', line 39 def adopt_expansion(node) @expanded = node @width = node.width @up = node.up @height = node.height @down = node.down @needs_space = node.needs_space end |
#expanded(_context = nil) ⇒ Object
35 36 37 |
# File 'lib/railroad_diagrams/expanded_node.rb', line 35 def (_context = nil) @expanded end |
#format(x, y, width) ⇒ Object
7 8 9 10 |
# File 'lib/railroad_diagrams/expanded_node.rb', line 7 def format(x, y, width) .format(x, y, width).add(self) self end |
#measure(context) ⇒ Object
16 17 18 |
# File 'lib/railroad_diagrams/expanded_node.rb', line 16 def measure(context) context.metrics((context)) end |
#render_svg(context, x, y, width) ⇒ Object
20 21 22 |
# File 'lib/railroad_diagrams/expanded_node.rb', line 20 def render_svg(context, x, y, width) Svg::Element.new('g', @attrs.dup) << (context).render_svg(context, x, y, width) end |
#render_text(context) ⇒ Object
24 25 26 |
# File 'lib/railroad_diagrams/expanded_node.rb', line 24 def render_text(context) (context).render_text(context) end |
#text_diagram ⇒ Object
12 13 14 |
# File 'lib/railroad_diagrams/expanded_node.rb', line 12 def text_diagram .text_diagram end |
#walk(callback) ⇒ Object
28 29 30 31 |
# File 'lib/railroad_diagrams/expanded_node.rb', line 28 def walk(callback) callback.call(self) child_nodes.each { |child| child.walk(callback) } end |