Class: RTree::Style
- Inherits:
-
RTreeC::StyleC
- Object
- RTreeC::StyleC
- RTree::Style
- Defined in:
- lib/rtree.rb,
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.
Class Method Details
.from_a(array) ⇒ RTree::Style Also known as: from_array
Create a new Style instance from array of Hash
542 543 544 |
# File 'lib/rtree.rb', line 542 def from_a(array) from_json(array.to_json) end |
.from_json(json) ⇒ RTree::Style
Create a new Style instance from JSON string
499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 |
# File 'lib/rtree.rb', line 499 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
490 491 492 |
# File 'lib/rtree.rb', line 490 def json_read(io) super end |