Class: Rubicus::Layers::Custom

Inherits:
Base
  • Object
show all
Defined in:
lib/rubicus/layers/custom.rb

Defined Under Namespace

Classes: AttrWriter

Constant Summary collapse

PROCS =
[ 
  [:data, :getdata],
  [:area, :areadef], 
]

Instance Method Summary collapse

Constructor Details

#initializeCustom

Returns a new instance of Custom.



5
6
7
# File 'lib/rubicus/layers/custom.rb', line 5

def initialize
  reset!
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(id, &block) ⇒ Object



38
39
40
# File 'lib/rubicus/layers/custom.rb', line 38

def method_missing(id, &block)
  do_block(id.to_s, &block)
end

Instance Method Details

#data=(rows) ⇒ Object



9
10
11
# File 'lib/rubicus/layers/custom.rb', line 9

def data=(rows)
  data {|a| a.data = rows }
end

#draw(image_type = "png", options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/rubicus/layers/custom.rb', line 13

def draw(image_type = "png", options = {})
  options[image_type] = nil if image_type
  ploticus_options = options.map { |key, option| "-#{key} #{convert_options(option)}" }.join(" ")
  io = IO.popen("ploticus -stdin #{ploticus_options}", "w+")
  io.write @s
  io.close_write
  img = io.read
  io.close
  img
end

#reset!Object



24
25
26
# File 'lib/rubicus/layers/custom.rb', line 24

def reset!
  @s = ""
end