Class: RTree::Style
- Inherits:
-
RTreeStyleBase
- Object
- RTreeStyleBase
- RTree::Style
- Defined in:
- lib/rtree.rb
Overview
A Ruby wrapper around RTree styles, used in PostScript plotting. in particular by #postscript.
Class Method Summary collapse
-
.from_a(array) ⇒ RTree::Style
(also: from_array)
Create a new Style instance from array of Hash.
-
.from_json(json) ⇒ RTree::Style
Create a new Style instance from JSON string.
-
.json_read(io) ⇒ RTree::Style
Create a new Style instance from JSON stream.
Methods inherited from RTreeStyleBase
Class Method Details
.from_a(array) ⇒ RTree::Style Also known as: from_array
Create a new Style instance from array of Hash
543 544 545 |
# File 'lib/rtree.rb', line 543 def from_a(array) from_json(array.to_json) end |
.from_json(json) ⇒ RTree::Style
Create a new Style instance from JSON string
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 |
# File 'lib/rtree.rb', line 500 def from_json(json) raise TypeError unless json.is_a? String rd, wr = IO.pipe(Encoding::UTF_8) if fork then wr.close begin result = json_read(rd) ensure rd.close Process.wait end else rd.close begin wr.write(json) ensure wr.close exit! end end result end |
.json_read(io) ⇒ RTree::Style
Create a new Style instance from JSON stream
491 492 493 |
# File 'lib/rtree.rb', line 491 def json_read(io) super end |