class Object

Behavior for custom classes

Public Instance Methods

test_icss() click to toggle source
# File lib/icss/receiver_model/to_geo_json.rb, line 1
def test_icss
  return <<EOF
---
namespace: foo.bar
protocol: baz
types:

- name: place
  doc: Foo bar place
  type: record
  fields:
  - name: name
    doc: Your name.
    type: string
  - name: website
    doc: Your website.
    type: url
EOF
end
to_yaml_properties() click to toggle source
# File lib/icss/serialization/zaml.rb, line 190
def to_yaml_properties
  instance_variables.sort        # Default YAML behavior
end
to_zaml(z=ZAML.new) click to toggle source
# File lib/icss/serialization/zaml.rb, line 196
def to_zaml(z=ZAML.new)
  z.first_time_only(self) {
    z.emit(zamlized_class_name(Object))
    z.nested {
      instance_variables = to_yaml_properties
      if instance_variables.empty?
        z.emit(" {}")
      else
        instance_variables.each { |v|
          z.nl
          v[1..-1].to_zaml(z)       # Remove leading '@'
          z.emit(': ')
          instance_variable_get(v).to_zaml(z)
        }
      end
    }
  }
end
zamlized_class_name(root) click to toggle source
# File lib/icss/serialization/zaml.rb, line 193
def zamlized_class_name(root)
  "!ruby/#{root.name.downcase}#{self.class == root ? '' : ":#{self.class.name}"}"
end