Module: Example

Defined in:
lib/msgpack/idl/command/example.rb

Overview

MessagePack IDL Processor

Copyright © 2011 FURUHASHI Sadayuki

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Constant Summary collapse

LIST =
[]

Class Method Summary collapse

Class Method Details

.add(name, summary, code) ⇒ Object



37
38
39
# File 'lib/msgpack/idl/command/example.rb', line 37

def self.add(name, summary, code)
	LIST << [name, summary, code]
end

.get(name) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/msgpack/idl/command/example.rb', line 25

def self.get(name)
	n, summary, code = LIST.find {|n, summary, code|
		name == n
	}
	unless code
		raise "unknown example name: #{name}"
	end
	result = "# #{name} - #{summary} example\n"
	result << code
	result
end

.listObject



21
22
23
# File 'lib/msgpack/idl/command/example.rb', line 21

def self.list
	LIST
end