File: invert_ruby.rb

package info (click to toggle)
gwyddion 2.67-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 54,152 kB
  • sloc: ansic: 412,023; python: 7,885; sh: 5,492; makefile: 4,957; xml: 3,954; cpp: 2,107; pascal: 418; perl: 154; ruby: 130
file content (36 lines) | stat: -rwxr-xr-x 738 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env ruby

# A very simple Gwyddion plug-in example in Ruby.

# Written by Nenad Ocelic <ocelic _at_ biochem.mpg.de>.
# Public domain.

$:.push(ENV['GWYPLUGINLIB'] + '/ruby')
require "gwyddion/dump"
include Gwyddion

# Plug-in information.
RUN_MODES= 'noninteractive', 'with_defaults'
PLUGIN_INFO= [ "invert_ruby", "/_Test/Value Invert (Ruby)"]

def register(args)
	puts PLUGIN_INFO, RUN_MODES.join(' ')
end 

def run( args)
	run_mode= args.shift
	RUN_MODES.member? run_mode or raise "Invalid run mode"
	
	dump= Dump.new args.shift
	a= dump[ '/0/data']
	
	n= a.length
	mirror= a.min + a.max
	for i in (0 ... n)
		a[ i]= mirror- a[ i]
	end
	dump.write # filename optional unless changed
end 

fn= ARGV.shift
send fn.intern, ARGV