Module: AsciiTree::EdgeParser
- Defined in:
- lib/ascii_tree/edge_parser.rb
Class Method Summary collapse
Class Method Details
.parse(string) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ascii_tree/edge_parser.rb', line 4 def parse(string) edge_chars_with_coordinates(string).map do |char, coordinate| offsets = edge_offsets[char] Edge.new( character: char, coordinate: coordinate, parent_coordinate: Coordinate.new( x: coordinate.x + offsets[:parent][:x], y: coordinate.y + offsets[:parent][:y] ), child_coordinate: Coordinate.new( x: coordinate.x + offsets[:child][:x], y: coordinate.y + offsets[:child][:y] ) ) end end |