Module: Simrpc::Schema
- Defined in:
- lib/simrpc/schema.rb
Overview
schema module defines classes / methods to define a simrpc schema / load it from an xml file
Defined Under Namespace
Classes: ClassDef, DataFieldDef, MethodDef, Parser, SchemaDef
Constant Summary collapse
- Types =
[ :str, :int, :float, :bool, :obj, :array ]
Class Method Summary collapse
-
.is_primitive?(type) ⇒ Boolean
return true if type is a primitive, else false.
-
.primitive_from_str(type, str) ⇒ Object
convert primitive type from string.
Class Method Details
.is_primitive?(type) ⇒ Boolean
return true if type is a primitive, else false
39 40 41 |
# File 'lib/simrpc/schema.rb', line 39 def is_primitive?(type) return [:str, :int, :float, :bool].include?(type) end |
.primitive_from_str(type, str) ⇒ Object
convert primitive type from string
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/simrpc/schema.rb', line 45 def primitive_from_str(type, str) if type == :str return str elsif type == :int return str.to_i elsif type == :float return str.to_f elsif type == :bool return str == "true" end end |